Primary Entities: Client Guest Reservation RoomAssignment
I want to implement a multiple room reservation database design. First, I want to explain first the concept:
The Guest is the one who is assigned into a specific room.
So for the Table:
Client (client_id(PK), Name)
Guest (guest_id(PK), Name)
Reservation (reservation_id(PK), client_id(FK), roomAss_id(FK), checkInDate);
RoomAssignment (roomAss_id(PK), guest_id(FK), roomno(FK));
Room(room_id(PK), roomDetails);
//The problem here is that I don't know how to implement a 1 to many relationship. My Reservation should handle mutliple RoomAssignment? Or my RoomAssignment will handle multiple guest_id and roomno and then I will pass 1 roomass_id into my reservation table?
Thanks I am really confused about this 1 to many relationship. I hope somebody is so kind to help instead of giving me negative points. T_T
Another Attempt:
Room(room_id(PK), roomDetails);
Client (client_id(PK), Name)
Guest (guest_id(PK), Name)
Reservation (reservation_id(PK), client_id(FK), checkInDate);
Booking(book_id(PK), reservation_id(FK), room_id(FK));
Lodging(lodge_id(PK), guest_id(FK), book_id(FK))
(Client, Room, Guest are already filled), add Reservation, add Booking, add Lodging
Is This Correct??
(Edit Changed my suggestion after thinking about this more. It's a deeper puzzle than I first thought.)
My preference would be to have the Reservation having a many-to-many relationship (using a bridge table) with rooms. Call this table, with ReservationID and RoomID foreign keys, something like . . . Booking. Maybe you can think of a better name. A Booking is a particular room being reserved. Then, I'd have another bridge table representing the relationship between a Guest and a Booking. You could maybe call that a Lodging. A Lodging is a particular guest being assigned to a particular Booking (a booked room).
This is a neat puzzle you have. The key is that you have several concrete things that exist on their own and are obviously necessary (reservation, room, guest), but also several other concepts, each with their own attributes, and spring from the relationship between these things. If this is going to be normalized correctly, you might end up with more tables than you guessed. Don't think of this as getting more complicated. Having the enough of the proper tables is what's going to ultimately simplify this. Here are some other suggestions: