Database structure question

Right now I’m trying to make sure I set up my database for the best performance speed wise, the bubble manual says this

  • For situations where data type A has connections to multiple Bs (e.g. posts having categories but only one category per post; A = category, B = post), having a field on B that references the A it belongs to is generally better. Having a field on A that lists out all the Bs that belong to it is not going to work as well when that list can get very long.

This seems backwards to me, if the goal is to show the a list of post within a category, wouldn’t saving each post to the category be faster, especially if there are a lot more post then categories ? I’m I missing something or not understanding correctly?

I hope not that this is through. But I normally do it both ways. So adding B to list of A and adding A to B. I cannot give you an example because itś out of my memory but I did have very complex searches where it was beneficial to have connections both ways.

1 Like

I do remember. Let’s say you create a payment system where you have a table in your database for invoices. Let’s say you have 1000 users and they all produce 100 invoices. Now you have 100.000 invoices. It’s possible to search for invoices for current user by checking the name of that user attached to that invoice (invoice creator). But Bubble needs to search 100.000 invoices. Do your shopping then :-). So yes you need to have that name of user in invoice table for users address on the invoice. But then in the user table you also add a list of invoices. So now Bubble just have to look up current user and present the list of invoices.