refactored database structure