User:Dantman/Abstract query language

We have no high-level query language. As a result any time you want to do queries of any level you are exposed to database internals. This means that if we have a reason to change the database schema in a way that changes old assumptions we can go and break a lot of code easily. Basically we're missing the "Model" in MVC in 90% of situations (only trivially simple cases and non-internal things using the API have any Model).

Advantages:
 * If the database structure changes, the generated sql for an abstract query will be different, the abstract query will not need to be updated to fit the new db structure as SQL would.
 * This flexibility would actually flex out even to extreme database changes. A user query could still be functional even if we dropped the entire user table, the rev_user_text field, and replaced them with a usermap table that maps anon ips and registered users to ids.
 * Because queries are written more abstractly individual db engines could theoretically set rules for certain types of queries to optimize them for that specific DB engine.
 * We should theoretically be able to keep our top MySQL performance.
 * We might also get better performance in other dbs like pgsql.

Syntax
A syntax like this is both powerful enough and separated enough to be capable of doing big queries like one of the ones we do in SpecialAllpages::showChunk.