Database refactoring3