db refactoring