Content is user-generated and unverified.

X Hotel Database Normalization: UNF to 3NF

(Based on Case Study Requirements and ERD Analysis)

Unnormalized Form (UNF) Example

Based on the X Hotel case study and your ERD design, here's a comprehensive example of data in UNF - a single flat table containing all information that would typically be collected in the hotel booking system:

Hotel_Booking_System_Complete (UNF)

HotelIDHotelNameEmailAddressBranchIDBranchLocationManagerIDManagerNameManagerEmailManagerPhoneCustomerIDFirstNameLastNameCustomerEmailContactNumberAddressReservationIDBookingDateCheckInDateCheckOutDateEmergencyContactSpecialRequestsRoomIDRoomNumberRoomTypeRoomRateCapacityRoomAvailableCheckInIDCheckInTimeCheckOutIDCheckOutTimeInvoiceIDInvoiceDescriptionTotalAmountCustomerNameFeedbackIDRatingReview
H001X Hotelinfo@xhotel.comBR001Kuala LumpurM001Ahmad Aliahmad@xhotel.com0187654321C001JohnSmithjohn@email.com0123456789123 Main St, KLR0012024-01-152024-02-012024-02-030198765432Late check-in, Non-smoking roomRM001, RM002101, 102Standard Double, Standard Twin150.00, 120.002, 2Yes, YesCI0012024-02-01 15:30CO0012024-02-03 11:00I001Room charges for 2 nights540.00John SmithF0015Excellent service and clean rooms!
H001X Hotelinfo@xhotel.comBR002PenangM002Siti Hassansiti@xhotel.com0187654322C002MaryJohnsonmary@email.com0123456790456 Oak Ave, PenangR0022024-01-202024-02-102024-02-120198765433Room service, High floorRM003201Deluxe Double200.002YesCI0022024-02-10 14:00CO0022024-02-12 10:30I002Deluxe room for 2 nights400.00Mary JohnsonF0024Great location, good facilities
H001X Hotelinfo@xhotel.comBR001Kuala LumpurM001Ahmad Aliahmad@xhotel.com0187654321C003DavidLeedavid@email.com0123456791789 Pine St, KLR0032024-01-252024-02-152024-02-170198765434Quiet room, Extra pillowsRM004103Standard Double150.002YesCI0032024-02-15 16:00CO0032024-02-17 11:30I003Standard room booking300.00David LeeF0033Average experience, room was okay

Critical Problems with UNF:

  1. Repeating Groups: Multiple room details (RoomID, RoomNumber, RoomType, etc.) in single row
  2. Data Redundancy: Hotel, Branch, and Manager information repeated for each booking
  3. Update Anomalies: Changing manager details requires updating multiple records
  4. Insert Anomalies: Cannot add new branches without having bookings
  5. Delete Anomalies: Deleting a booking loses branch/manager information
  6. Inconsistent Data: Multiple values in single cells violate atomic value rule
  7. Storage Waste: Massive duplication of data

STEP 1: Convert UNF to First Normal Form (1NF)

Rule for 1NF:

  • Each cell must contain only atomic (single) values
  • Each record must be unique
  • No repeating groups allowed

Actions Taken:

  1. Eliminate Repeating Groups: Separate multi-valued attributes (RoomID, RoomNumber, RoomType, RoomRate, Capacity)
  2. Create Atomic Values: Split combined room information into separate rows
  3. Ensure Unique Records: Each row represents one room in one booking
  4. Establish Primary Key: Use composite key (ReservationID, RoomID)

Tables in 1NF:

Hotel_Booking_System_1NF

HotelIDHotelNameEmailAddressBranchIDBranchLocationManagerIDManagerNameManagerEmailManagerPhoneCustomerIDFirstNameLastNameCustomerEmailContactNumberAddressReservationIDBookingDateCheckInDateCheckOutDateEmergencyContactSpecialRequestsRoomIDRoomNumberRoomTypeRoomRateCapacityRoomAvailableCheckInIDCheckInTimeCheckOutIDCheckOutTimeInvoiceIDInvoiceDescriptionTotalAmountCustomerNameFeedbackIDRatingReview
H001X Hotelinfo@xhotel.comBR001Kuala LumpurM001Ahmad Aliahmad@xhotel.com0187654321C001JohnSmithjohn@email.com0123456789123 Main St, KLR0012024-01-152024-02-012024-02-030198765432Late check-in, Non-smoking roomRM001101Standard Double150.002YesCI0012024-02-01 15:30CO0012024-02-03 11:00I001Room charges for 2 nights540.00John SmithF0015Excellent service and clean rooms!
H001X Hotelinfo@xhotel.comBR001Kuala LumpurM001Ahmad Aliahmad@xhotel.com0187654321C001JohnSmithjohn@email.com0123456789123 Main St, KLR0012024-01-152024-02-012024-02-030198765432Late check-in, Non-smoking roomRM002102Standard Twin120.002YesCI0012024-02-01 15:30CO0012024-02-03 11:00I001Room charges for 2 nights540.00John SmithF0015Excellent service and clean rooms!
H001X Hotelinfo@xhotel.comBR002PenangM002Siti Hassansiti@xhotel.com0187654322C002MaryJohnsonmary@email.com0123456790456 Oak Ave, PenangR0022024-01-202024-02-102024-02-120198765433Room service, High floorRM003201Deluxe Double200.002YesCI0022024-02-10 14:00CO0022024-02-12 10:30I002Deluxe room for 2 nights400.00Mary JohnsonF0024Great location, good facilities
H001X Hotelinfo@xhotel.comBR001Kuala LumpurM001Ahmad Aliahmad@xhotel.com0187654321C003DavidLeedavid@email.com0123456791789 Pine St, KLR0032024-01-252024-02-152024-02-170198765434Quiet room, Extra pillowsRM004103Standard Double150.002YesCI0032024-02-15 16:00CO0032024-02-17 11:30I003Standard room booking300.00David LeeF0033Average experience, room was okay

Primary Key: (ReservationID, RoomID)

Achievements:

  • ✅ All cells contain atomic values
  • ✅ Each record is unique
  • ✅ No repeating groups
  • ❌ Still has redundancy and anomalies

STEP 2: Convert 1NF to Second Normal Form (2NF)

Rule for 2NF:

  • Must be in 1NF
  • All non-key attributes must be fully functionally dependent on the entire primary key
  • Eliminate partial dependencies

Functional Dependencies Analysis:

Primary Key: (ReservationID, RoomID)

Full Dependencies (depend on both ReservationID AND RoomID):
- None identified (this is the problem!)

Partial Dependencies (depend on only part of the key):
ReservationID → CustomerID, FirstName, LastName, CustomerEmail, ContactNumber, Address, BookingDate, CheckInDate, CheckOutDate, EmergencyContact, SpecialRequests, BranchID, CheckInID, CheckInTime, CheckOutID, CheckOutTime, InvoiceID, InvoiceDescription, TotalAmount, CustomerName, FeedbackID, Rating, Review

RoomID → RoomNumber, RoomType, RoomRate, Capacity, RoomAvailable, BranchID

Additional Dependencies:
CustomerID → FirstName, LastName, CustomerEmail, ContactNumber, Address
BranchID → BranchLocation, ManagerID, HotelID
ManagerID → ManagerName, ManagerEmail, ManagerPhone
HotelID → HotelName, EmailAddress
InvoiceID → InvoiceDescription, TotalAmount, CustomerName
FeedbackID → Rating, Review
CheckInID → CheckInTime
CheckOutID → CheckOutTime

Actions Taken: Create separate tables to eliminate partial dependencies

Tables in 2NF:

Hotel

HotelIDHotelNameEmailAddress
H001X Hotelinfo@xhotel.com

Primary Key: HotelID

Manager

ManagerIDManagerNameManagerEmailManagerPhone
M001Ahmad Aliahmad@xhotel.com0187654321
M002Siti Hassansiti@xhotel.com0187654322

Primary Key: ManagerID

Branch

BranchIDBranchLocationManagerIDHotelID
BR001Kuala LumpurM001H001
BR002PenangM002H001

Primary Key: BranchID Foreign Keys: ManagerID → Manager(ManagerID), HotelID → Hotel(HotelID)

Customer

CustomerIDFirstNameLastNameCustomerEmailContactNumberAddress
C001JohnSmithjohn@email.com0123456789123 Main St, KL
C002MaryJohnsonmary@email.com0123456790456 Oak Ave, Penang
C003DavidLeedavid@email.com0123456791789 Pine St, KL

Primary Key: CustomerID Unique Constraint: CustomerEmail

Room

RoomIDRoomNumberRoomTypeRoomRateCapacityRoomAvailableBranchID
RM001101Standard Double150.002YesBR001
RM002102Standard Twin120.002YesBR001
RM003201Deluxe Double200.002YesBR002
RM004103Standard Double150.002YesBR001

Primary Key: RoomID Foreign Key: BranchID → Branch(BranchID)

Reservation

ReservationIDCustomerIDBranchIDBookingDateCheckInDateCheckOutDateEmergencyContactSpecialRequests
R001C001BR0012024-01-152024-02-012024-02-030198765432Late check-in, Non-smoking room
R002C002BR0022024-01-202024-02-102024-02-120198765433Room service, High floor
R003C003BR0012024-01-252024-02-152024-02-170198765434Quiet room, Extra pillows

Primary Key: ReservationID Foreign Keys: CustomerID → Customer(CustomerID), BranchID → Branch(BranchID)

Reservation_Room (Junction Table)

ReservationIDRoomID
R001RM001
R001RM002
R002RM003
R003RM004

Primary Key: (ReservationID, RoomID) Foreign Keys: ReservationID → Reservation(ReservationID), RoomID → Room(RoomID)

CheckIn

CheckInIDReservationIDCheckInTime
CI001R0012024-02-01 15:30
CI002R0022024-02-10 14:00
CI003R0032024-02-15 16:00

Primary Key: CheckInID Foreign Key: ReservationID → Reservation(ReservationID)

CheckOut

CheckOutIDReservationIDCheckOutTime
CO001R0012024-02-03 11:00
CO002R0022024-02-12 10:30
CO003R0032024-02-17 11:30

Primary Key: CheckOutID Foreign Key: ReservationID → Reservation(ReservationID)

Invoice

InvoiceIDReservationIDInvoiceDescriptionTotalAmountCustomerName
I001R001Room charges for 2 nights540.00John Smith
I002R002Deluxe room for 2 nights400.00Mary Johnson
I003R003Standard room booking300.00David Lee

Primary Key: InvoiceID Foreign Key: ReservationID → Reservation(ReservationID)

Feedback

FeedbackIDReservationIDRatingReview
F001R0015Excellent service and clean rooms!
F002R0024Great location, good facilities
F003R0033Average experience, room was okay

Primary Key: FeedbackID Foreign Key: ReservationID → Reservation(ReservationID)

Achievements:

  • ✅ All partial dependencies eliminated
  • ✅ Data redundancy significantly reduced
  • ✅ Update anomalies mostly resolved
  • ❌ Some transitive dependencies still exist

STEP 3: Convert 2NF to Third Normal Form (3NF)

Rule for 3NF:

  • Must be in 2NF
  • Eliminate all transitive dependencies
  • No non-key attribute should depend on another non-key attribute

Transitive Dependencies Analysis:

Transitive Dependencies Found:

In Invoice table:
ReservationID → CustomerID → FirstName, LastName (CustomerName)
This creates: InvoiceID → ReservationID → CustomerID → CustomerName

In Branch table:
BranchID → ManagerID → ManagerName, ManagerEmail, ManagerPhone
(Already properly normalized - Manager is separate entity)

In Room table:
RoomID → BranchID → BranchLocation, ManagerID, HotelID
(Already properly normalized - Branch is separate entity)

Actions Taken: Remove transitive dependencies

Final Tables in 3NF:

Hotel

HotelIDHotelNameEmailAddress
H001X Hotelinfo@xhotel.com

Primary Key: HotelID

Manager

ManagerIDManagerNameManagerEmailManagerPhone
M001Ahmad Aliahmad@xhotel.com0187654321
M002Siti Hassansiti@xhotel.com0187654322

Primary Key: ManagerID

Branch

BranchIDBranchLocationManagerIDHotelID
BR001Kuala LumpurM001H001
BR002PenangM002H001

Primary Key: BranchID Foreign Keys: ManagerID → Manager(ManagerID), HotelID → Hotel(HotelID)

Customer

CustomerIDFirstNameLastNameCustomerEmailContactNumberAddress
C001JohnSmithjohn@email.com0123456789123 Main St, KL
C002MaryJohnsonmary@email.com0123456790456 Oak Ave, Penang
C003DavidLeedavid@email.com0123456791789 Pine St, KL

Primary Key: CustomerID Unique Constraint: CustomerEmail

Room

RoomIDRoomNumberRoomTypeRoomRateCapacityBranchID
RM001101Standard Double150.002BR001
RM002102Standard Twin120.002BR001
RM003201Deluxe Double200.002BR002
RM004103Standard Double150.002BR001

Primary Key: RoomID Foreign Key: BranchID → Branch(BranchID) Note: RoomAvailable removed (should be calculated based on reservations)

Reservation

ReservationIDCustomerIDBranchIDBookingDateCheckInDateCheckOutDateEmergencyContactSpecialRequests
R001C001BR0012024-01-152024-02-012024-02-030198765432Late check-in, Non-smoking room
R002C002BR0022024-01-202024-02-102024-02-120198765433Room service, High floor
R003C003BR0012024-01-252024-02-152024-02-170198765434Quiet room, Extra pillows

Primary Key: ReservationID Foreign Keys: CustomerID → Customer(CustomerID), BranchID → Branch(BranchID)

Reservation_Room

ReservationIDRoomID
R001RM001
R001RM002
R002RM003
R003RM004

Primary Key: (ReservationID, RoomID) Foreign Keys: ReservationID → Reservation(ReservationID), RoomID → Room(RoomID)

CheckIn

CheckInIDReservationIDCheckInTime
CI001R0012024-02-01 15:30
CI002R0022024-02-10 14:00
CI003R0032024-02-15 16:00

Primary Key: CheckInID Foreign Key: ReservationID → Reservation(ReservationID)

CheckOut

CheckOutIDReservationIDCheckOutTime
CO001R0012024-02-03 11:00
CO002R0022024-02-12 10:30
CO003R0032024-02-17 11:30

Primary Key: CheckOutID Foreign Key: ReservationID → Reservation(ReservationID)

Invoice

InvoiceIDReservationIDInvoiceDescriptionTotalAmountPaymentDate
I001R001Room charges for 2 nights540.002024-01-16
I002R002Deluxe room for 2 nights400.002024-01-21
I003R003Standard room booking300.002024-01-26

Primary Key: InvoiceID Foreign Key: ReservationID → Reservation(ReservationID) Note: CustomerName removed (get from Reservation → Customer relationship)

Feedback

FeedbackIDReservationIDRatingReview
F001R0015Excellent service and clean rooms!
F002R0024Great location, good facilities
F003R0033Average experience, room was okay

Primary Key: FeedbackID Foreign Key: ReservationID → Reservation(ReservationID)


Summary of Normalization Process

Problems Eliminated:

Data Redundancy:

  • Before: Customer info repeated in every room booking
  • After: Customer info stored once in Customer table

Update Anomalies:

  • Before: Changing manager info required updating multiple records
  • After: Manager info updated once in Manager table

Insert Anomalies:

  • Before: Cannot add new branch without existing bookings
  • After: Can add branches independently

Delete Anomalies:

  • Before: Deleting booking loses branch/manager information
  • After: Branch/manager info preserved independently

Key Design Decisions:

  1. Hotel Entity: Included to support multi-hotel expansion
  2. Separate Check-in/Check-out: Allows flexible timing management
  3. Junction Table: Handles many-to-many relationship between reservations and rooms
  4. Room Availability: Calculated field rather than stored attribute
  5. Customer Name in Invoice: Removed to eliminate transitive dependency

Business Rules Enforced:

  1. Unique Email: Prevents duplicate customer registrations
  2. Branch-Room Relationship: Ensures rooms belong to specific branches
  3. Reservation-Branch Consistency: Customers can only book rooms from one branch per reservation
  4. Manager-Branch Relationship: Each branch has exactly one manager
  5. Rating Scale: 1-5 scale maintained through application logic

Final Database Benefits:

  • Minimal Redundancy: Each piece of data stored once
  • Data Integrity: Referential integrity through foreign keys
  • Scalability: Easy to add new hotels, branches, rooms
  • Flexibility: Supports complex booking scenarios
  • Maintainability: Changes isolated to specific tables
  • Performance: Optimized for queries and updates

This 3NF design provides a robust, scalable foundation for X Hotel's booking management system that fully meets all case study requirements while maintaining optimal database structure.

Content is user-generated and unverified.
    X Hotel Database Normalization: UNF to 3NF | Claude