basic DB operations written, ready for heavy refactoring before tying to
existing application functions.