I have a question about my database structure. I’m making an app where a user records his debts and people that owe him. My current structure is:
{people: {
person1: {
name: John
total: 177
},
person2: {
name: Peter
total: 67
},
},
{transactions: {
person1: {
{transaction1: { amount: 100 },
{transaction2: { amount: 77 }
},
person2: {
{transaction1: { amount: 7 },
{transaction2: { amount: 20 }
{transaction3: { amount: 10 },
{transaction4: { amount: 30 }
},
},
Every time a transaction is added or deleted, I update that person's total using ref.transaction().
So, each addition or removal use 2 remote calls.
My question: Am I doing it right?