refactor database tables