Forum Academy Marketplace Showcase Pricing Features

Many to many relationship / CreateOrUpdate logic / List in List

Hi, I’m quite new to bubble but worked years on database structures.
I can’t get my head around bubbles relational database model, quite frustrating.

First of all, I made it work, but I don’t feel like its best practice :smiley:

Somehow I got stucked with a typical use case I’m trying to make work.

I have build these tables in this way:
Orders ([User], List of [Orderitems])
Orderitems ([Products], Amount)
Products ([Name])

Is there an easier way for this many-to-many relationship in bubble?

Now let’s say the user clicks on a product to add to his/her order.
I need to check first if that user has an [Order], otherwise create a new one → Do I really need “Create a thing… with a condition if no order can be found” + another action “Change a thing… with the condition that an order exist”? I wonder if I miss the obvious because I needed to do the same for the Orderitem (Add a new one OR increase Amount+1 for an existing one).

On UI level I added a ‘reusable list’ inside a ‘reusable list’ because I want to show all Orders (First list) and inside all Orderitems for that Order (Second list)

Maybe someone can point me to a best practice solution for this? All the trainings I found do not cover these use cases