This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Varuna Seneviratna
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Varuna Seneviratna
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob!!!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic