aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 19556
    
  16

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!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the relationship between a Guest and a room booked by the guest in a hotel
 
Similar Threads
Multiple Clients: Use Observer Pattern ?
Can update every fields?
URLyBird Search all records
UrlyBird - they take booking only within 48 hours...
About the the meaning of several record fields