Earlier this morning, I almost finished the “parent tables” part of my project. It was really, really long but interesting too.
Let me explain it to you in simple terms (as I explained it in my previous article):
Let’s say we have two tables: Books and Authors. And while declaring the table Books, Authors table has been declared as parent table. Then, in Special:Drilldown of the `Books` tables, not only filters for just `Books` table, but also the filters for the `Authors` table will be shown such that search for a book can include not just fields directly related to the `Books` table, like its genre and language, but also fields for its parent table (`Authors`), like the nationality of its author.
Initially I was implementing it by using nested join conditions and it was working perfectly in starting but it started giving errors when I changed the result format to “timeline” instead of “Maps” or “category” (the default one). I knew that these format were creating SQL queries differently (the reason behind this is that “category” or “map” formats uses or handles the database according to the MediaWiki’s core Database class but “timeline” format (or more precisely Deferred formats according to Cargo) uses or handles the database according to CargoSQLQuery class (i.e. for creating the same SQL query, for “category” or “map” format will input different parameters to ‘Database’ class and “calendar” format will input different parameters to ‘CargoSQLQuery’ class)). And I didn’t know how to create nested join conditions in ‘CargoSQLQuery’ class. I tried to find the answer but instead I found a way out. Instead of using nested join conditions, I reformatted them a little so that they were not nested now. For instance:
SELECT fields FROM `main_table`
LEFT OUTER JOIN ( `parent`
LEFT OUTER JOIN `parent__list` ON ( `parent`._ID = `parent__list`._rowID )
ON ( `main_table`.`localfield` = `parent__list`._value )
SELECT fields FROM `main_table`
LEFT OUTER JOIN `parent__list` ON ( `main_table`.`localfield` = `parent__list`._value )
LEFT OUTER JOIN `parent` ON ( `parent`._ID = `parent__list`._rowID )
After that it was perfectly working with “timeline” result format too.
But then, when I and Yaron (my mentor) were discussing more about this and how the Special:Drilldown page should look after this, then he came up with a case in which same table can be used as two different “parent tables”. For instance, a company could have “President” and “CEO”, two different fields, each pointing to the table “People”, and have “People” as a parent table for both. Then we agreed that this feature should be added too and it was pretty straight forward by using alias. Alias hasn’t been used in Special:Drilldown before. So, I had to add it everywhere in it and It was somewhat boring. I did it too. And now, we’re working on the look of Drilldown page after adding parent tables.
When changing the appearance of Special:Drilldown after that, I learned many new things too like CSS Gradients and its use with fieldset and legend. When you apply background color in fieldset, it’ll look really bad, you need to use gradients if you want any color in your fieldset. And for adding gradients, you may use background image, but CSS gradients are way cooler. If you don’t know about CSS Gradients, you must read it (here you go: Using CSS Gradients, Linear-Gradient, Radial-Gradient), they are interesting. By just using gradients, you can produce something like:
Patch for this task can be found here.
Thanks for reading…