I have a schema in the effect of the following, simplified to illustrate my point:
users
tablebank_deposits
table – belongs to userorders
table – belongs to usertransactions
table – which contains debit/credit transactions
Where transactions
is related to either bank_deposits
OR orders
but not both at the same time — and so related to users
through them.
I want a simple way to get ALL transactions
belonging to the user (to calculate balance) but adding a user_id
column directly in transactions
would be redundant.
In reality, there are more tables between bank_deposits
/orders
and transactions
so I really want to avoid complicated the queries.
Should I add a redundant user_id
column in transactions
for efficiency sake?