Refactoring db structure