refactor database model