How to avoid SQL fanout in this situation?
I may be incorrect in saying it’s a fanout, but I think that’s what it is. To start with, I’m using Drizzle ORM. Essentially, I have 4 tables in question: one is a bills table, another is a UsersToBills junction table, the third is the users table, and the fourth is an expenses table(I don’t have a junction table for expenses because I store the billId inside the Expenses schema). To keep it brief, a bill can have both multiple users and multiple expenses associated with it. What I’m trying to do is query an array of all the bills, where each bill has
its information along with the arrays of both users and expenses associated with it: In pseudocode, this is my desired structure: