Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I structure a Bookings table for two models?

Taylor Cooney asked in Databases

I've primarly built out support to book a flight, and now I'm looking to offer the ability to book a hotel as well. I'm looking for some insight on the best way to model this:

Currently there is a Reservations table that has a flight_id and user_id. Does it make sense to create an entirely new table for Hotel reservations, or modify the exisiting Reservations table to support polymorphic assocaitons? Instead of flight_id, it would have a reservable_type and reservable_id. Off the top of my mind, ActiveRecord will be unable to build any join from a polymorphic assocation without additional information.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.