Master class for working with database

Hopefully this will be an orderly and maintainable way to edit the existing
graph without having to delete the whole thing and spend days rebuilding more
than 40k relationships.