factor out db classes and methods.