refactor db model to use base classes for Table and Model