Fixing database structure