Refactoring of database structure for more complex use cases