First stab at the DB interface. About halfway done