[30] Start implementing database queries

* Also cleaned up hardcoded database related strings, allowing easier
replacement with a buch of constants