Expand all | Collapse all

Many to Many Table?

  • 1.  Many to Many Table?

    Posted 10-30-2017 16:25
    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.


  • 2.  RE: Many to Many Table?

    Posted 10-30-2017 16:33


    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.

  • 3.  RE: Many to Many Table?

    Posted 10-30-2017 16:45
    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.

  • 4.  RE: Many to Many Table?

    Posted 10-30-2017 21:41
    Great, thank you Matthew and Chris. I've begun work adding this to our API!