more work towards db layer

Signed-off-by: derwinlu <derwinlu+git@gmail.com>