GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes What is the relationship between a Guest  and a room booked by the guest in a hotel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the relationship between a Guest  and a room booked by the guest in a hotel" Watch "What is the relationship between a Guest  and a room booked by the guest in a hotel" New topic
Author

What is the relationship between a Guest and a room booked by the guest in a hotel

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
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?


Varuna Seneviratna
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

I'd use the booking as an intermediate.

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
Thanks Rob!!!
 
GeeCON Prague 2014
 
subject: What is the relationship between a Guest and a room booked by the guest in a hotel