Last modified: 2014-09-29 12:53:47 UTC
The badges of sitelinks should be stored in another table to make them queryable. This table should contain a badge id and the sitelinks site and wiki. Alternativly, we can add the badges to the wb_items_per_site table but this might become tricky because there is a primary key on the siteid/page columns so we cannot create a new row for each badge but have to put them all into one value which then makes querying them harder and not really efficient.
I think this should get higher priority because it blocks removal of the badge templates from some Wikipedias. I want some discussion in the development team first how the database table should look like before we proceed with implementing this part of the badges.
I'm not sure I agree that we need such a table (but I can be convinced). In any case, the basic structure should be: ( badge, siteId, page ) with the primary key covering all three fields, in this order. This allows us to efficiently find all pages that have a given badge, on all sites or a given site. If we also want to be able to find all the badges associated with a given page (on a given site), we'd need another index covering ( siteId, page ). This would be useful if we wanted to show badges in listings of pages (e.g. add icons for special pages in the Special:Allpages listing. For convenience, we may want to have a column for the associated item id. This would remove the need to join against wb_item_per_site in cases where we need to know the item ID. However, we generally don't care about the associated item in this context, do we?
@daniel if we don't need such table, then how do you suggest we make badges / badge usage queryable?