Forum Discussion

ltduranltduran's avatar
ltduranltduran
Qrew Cadet
8 years ago

Many to Many Table?

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?
  • ChrisChris's avatar
    ChrisChris
    Qrew Assistant Captain

    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.

  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    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.