Many to Many relationship

Hi, a few thoughts…

I think you’ll find that the list field will be what you’re primarily using, since those list fields will only be holding a handful of records.

I assume a “Customer” is someone who can sign in, see their info and take actions, however a “Dependent” is not. So the “Customer” will be Bubble’s special User datatype (ie datatable), whereas “Dependent” is a regular datatype.

You can point your list fields one way or the other (or both ways if there is a reason to do so). For example, a Customer (ie User) can have a field with a list of Dependents, or vice versa. Both will work in terms of creating the relationships, searching and displaying data.

In terms of which way to point is best, I don’t have any definitive advice… in my app I do a mixture based on…
a) All else being equal, a shorter list field is better than a longer list field, because it makes the record “lighter”
b) Which is easier for Bubble to search and display for my specific use cases. I’m especially sensitive to this in repeating groups, since the load on Bubble will multiply
c) Which is easier to maintain as I’m editing records
d) Ensuring my setup will allow my privacy rules (a privacy rule can only look to the User datatype and the datatype you’re setting the rule on; it can look to list fields in either, but not beyond that)

I do use joining tables to create many-to-many relationships in some situations, mainly to avoid long lists, since the conventional thinking is that long lists aren’t good. For example, in my app, Users can favorite Items, and I store those relationships in joining tables rather than in a field on the Item or User record.

There has been a lot of ink spilled on which way to point list fields and when to use joining tables. Some reading I found helpful was:

This mega thread: Alternative approach to the Bubble’s recent tutorials for list of things

Great book (in my view, essential for anyone building a complex app that needs to scale): The Ultimate Guide to Bubble Performance - the new edition is out (now 210 pages!) - #73 by petter

Bubble’s documentation; Creating a Data Structure - Bubble Docs

4 Likes