Improved db schema. Abstracted db calls.

To prepare for possible different database types, the Database class
is now generic, and calls a database specific class.

Currently we only support PostgreSQL, but that might change.