db architecture refactoring