Using "Relationship" things instead of "Linking fields"

Recently i’m considering to use a different method for associating data for the reasons below, and i’m interested to hear what could be the disadvantages:

Instead of using “linking fields” to associated data, rather treat the relationship as a thing in itself, that is: creating a data type called “relationships”, and have a field for both things, for example “Orders” to “Customers”.

Here is the advantage:

  1. Instead of creating 2 actions for “adding” each other to its “linking fields”, create a new “relationship” thing with those 2 things included.

  2. Instead of creating 2 actions for “removing” each other from its “linking fields”, delete this corresponding “relationship” thing.

Any negative implications with this structure?

1 Like

It isn’t a bad idea, there is something called an “Association Class” that does pretty much the same thing. So for example if you have two users you can create such a link that describes how they are related.

However, by not having the list of “Orders” or “Relationships” on the “Customer” you are in danger of making Bubble search the whole of the “Relationship” table looking for particular customers.

Imagine you have a million customers. Each has 100 orders.

If you want a list of orders for a customer to be displayed, do you want to a) find the 100 attached to the customer thing, the put them in some sort of order or b) search through 100 million records looking for one in a million records, then sort them.

Now, imagine you do the same thing with “Order Category” on your Order thing.

And this time you want to find all “Food” orders for a customer. There are 100 different categories.

Search through 100 million records, and for each of those, search through up to to 100 categories to find “Food”.

That’s ten billion.

Or… look through 100.

You are prioritising making one particular thing that you do infrequently (delete something) against something you do a lot. (search for stuff).

4 Likes

I do both. It’s a bit more up front work on my end, but it makes things easier for me down the road. I’ve found in situations it’s helpful to have the relationship object, but for most cases, I want the list of things referenced directly, for all the reasons Nigel mentions.

3 Likes