What is the relationship between a Guest and a room booked by the guest in a hotel
posted 7 years ago
What is the relationship between a Guest class and a Room class booked by a guest in a hotel.Is there a need of a in between Booking class.It is not any one like Has-a Or Is-a isn't it I think it is Gust Booked Room and the Booking class comes between the Guest class and the Room class as the linking class. Am I right?
A guest can, over time, have had multiple rooms. Every room will have had multiple guests. In other words, it is a many-to-many relation. In database design this is usually solved by a table to link the two, in this case the booking. Then you say a booking HAS-A guest and HAS-A room, and both a guest and a room HAVE-MULTIPLE (a form of HAS-A with arrays / collections) bookings.