I’m planning a booking system in rails, and I have the following issue:
There will be room_types. I can implement this with STI in the rooms
table, or with a separate table room_types. Each room type will have its
Room::SingleRoom # For 1 person
Room::DoubleRoom # Simply for 2 people
Room::DoubleRoom::SingleDoubleRoom # If only for 1 person will be
Room::DoubleRoom::ExtraBedDoubleRoom # 3 people can use it (more
Room::Apartment # For example, between 4-6 people, with different prices
There is another approach, with a room_types table. It can take care of
the capacities of the different rooms, allowing the customers to search.
The table structure can be something like:
name: the RoomType name
default_capacity: The mainly used capacity (2 In case of
maximum_capacity: The room allows more people (3 In case of
minimum_capacity: If the customer uses this type of room but with a
value lesser than this, will pay the price assigned to this minimum (2
In case of ExtraBedDoubleRoom)
Remember that the system must be searchable, so the typical STI solution
doesn’t fit well, since I must then specify the capacities in the code!
Some kind of hybrid makes more sense to me. Is there any other approach?
How do you would do it?