Database refactoring2