Refactoring database