Bug 826065: database interface rewrite; r=mcote

This moves all of the database code into purpose-specific classes, then
combines those all in a nice facade.  The current DB object is passed
around, rather than being a global; this
 * presents minimal difficulty
 * ensures that only code that should be talking to the DB does
 * ensures that a given server instance shares exactly one instance of
   the DB interface