Refactoring database creation