Many to many relationships

I’m struggling with many-to-many here. My goal is

  • have a list of members
  • have a list of possible events
  • members can choose which events they are going to
  • on the app show an event and who is attending that

I saw this post referencing 3 sheets Many-to-Many Relationships - #22 by Alfonso_Aguilar but the sample is not there anymore.

Something isn’t clicking for me even after watching all the videos on relationships in Glide.

Hi @timheuer

I know you said you have watched videos, just checking that you have seen this one?

And read this

https://docs.glideapps.com/all/reference/data-editor/computed-columns/relation-column#multiple-relations

Yes unfortunately those are not helping me…I’m clearly missing something in my brain.

In a normal database I’d have 3 tables: members, events, memberevents – I’m just not seeing how 3 sheets then map using this relational column concept and still show me the values i want

Hi @timheuer.

It was a long time ago and some current features were not available then… Here is a link to the sample app: https://many2many-norep.glideapp.io.

Take a look to the data tables in the app. You will find 3 tables:

  1. Events table: you list of possible events.
  2. Participants table: your list of members.
  3. Attendees table: your list of “memberevents". When a member chooses to go to an event, you create a row in this table.

Instead of creating a "many-to-many” relation between Events and Participants, you should create 2 “one-to-many” relations:

  1. Events(1)-to-Attendees(many): one event can have relate to many member-event pairs (or have many participants).
  2. Participants(1)-to-Attendees(many): one member can relate to many member-event pairs (or "be an attendee” to many events).

When a member chooses to attend an event, you just need to create a new member-event pair in the Attendees table. You can traverse the relations to grab data from the related tables using LookUp columns.

Hope this helps.

3 Likes

Thanks @Alfonso_Aguilar this is helpful to look at – I’ve made more progress. Now trying to display the right things on the form is hard:

Done - I want a Member screen that shows the name of all events they are getting
Done - A list of events
Not figured out - Look at the event details and show a list of names that are registered (not the unique key) and allow link to the details of that member

You can use a LookUp column.

Notice that to reach the Participants table from the Events table you have to traverse 2 relations: Events-to-Attendees and Attendees-to-Participants. For your reference,I have added a new LookUp column to the Events table in the sample app. You may need to get an updated copy of the app (link: https://many2many-norep.glideapp.io/).

Please, have a look at it and try to do the same in your app:

Step 1. In your Events data table, create a LookUp column and configure it to reach into the Participants table through the necessary relations (Events-to-Attendees > Attendees-to-Participants).
Step 2. In your Events layout, select the LookUp column created in Step 1 as the source for the values in the list of attendees.
Step 3. You should now see and be able to use Participants data to populate list entries.
Step 4. By default, tapping on any entry in the list will show the Participant details (you can change this by selecting a different action in the list Features tab).

Good luck!

1 Like