I want to design a database structure for a hotel reservation system.
My schema:
client (
client_id,
lastname
)
reservation (
reservation_id,
client_id,
checkIndate,
roomno
)
My problem is in the check-in part. I have already created a reservation; do I still need to create a check-in table? If so, what should its schema be?
There are two ways customers can enter a hotel:
- by reservation (reserving a room prior to arrival) or
- by checkIn (goes to the hotel without reservation)
How Do I store the records that are checked-IN in the hotel??
Just a couple of thoughts. I notice that “roomno” is a field in the “reservation” table. I assume then that you also have a “room” table, which has “roomno” as its primary key and whatever other data that you might keep track of on a room (phone_number, number_of_beds, etc…).
What I would do, is create a table called “Occupancy”. This table would have three fields “client_id”, “roomno”, and checkin_time. “client_id” and “roomno” would both be foreign keys (to the client and room tables, respectively). To ensure uniqueness, I’d concatenate them both to make the primary key (after all, you could have one client buy two rooms).
When the client checks-out, you would remove that row from the “Occupancy” table. You’ll want to archive that row in another table (“history”, “pastStays”…something like that) where you’ll also want to log the “checkout_time”.
In terms of the changes that I have suggested or assumed, here is how they’d look: