Many to Many Table?

  • 1
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I have two tables:

  1. Bookings (Key Field = Booking ID)
  2. Events (Key Field = Event ID)
The Bookings table has the Event ID as a field. The Events table does NOT have the Booking ID as a field because an event might have many Booking ID's associated. Practically speaking, one Event might have many Bookings; however, I need to bring data from the Booking table into the Game table as it related to the Event ID. I feel that perhaps a many-to-many intermediary table is needed, but I'm not sure how to make this happen. I would like to keep the Event table as a parent table to the Bookings table so that I can view all the bookings associated with an Event, but I also want to bring some fields down to the Event table.

I feel as if I should mention that both tables are connected to our booking site via API. All records in both tables are added whenever a booking is created on our booking site.

Thoughts?
Photo of ltduran

ltduran

  • 590 Points 500 badge 2x thumb

Posted 1 year ago

  • 1
  • 1
Photo of Chris

Chris, Champion

  • 4,390 Points 4k badge 2x thumb

Hi,

To form many to many relationships you need three tables.

Your third table would be the Details table and it is the child to both the Bookings table and child to the Event table.

the Details table will select the Booking ID and the Event ID in each of its records. This configuration allows many Bookings to have many Events and many Events to have many Bookings.

If I understand you correctly, this will provide the solution you're looking for.

Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
To add to chris...

you will want to add that child/joined table to your API so that joined records are created at the same time as well.
Photo of ltduran

ltduran

  • 590 Points 500 badge 2x thumb
Great, thank you Matthew and Chris. I've begun work adding this to our API!