Refactoring of database