I have a transaction table that logs credits and debits. The numbers are always int (-1 to usually 100). My issue is that Debits have a lot more data than credits, and it feels weird having this data in the same table.
Columns
ID |
ClientID |
CardCodeID |
ClientDeviceID |
ClientEmployeeID |
ProjectID |
PlantID |
MaterialID |
Amount |
CreatedAt
A credit only uses ClientID, Amount,MaterialID and CreatedAt, and a Debit uses All the columns. Is there a more effecient way to design this table?
Best Answer
Given balances are a sum of amounts, you are storing one of debits or credits as negative right?, the same table is ok. Having a few NULLable fields is ok too even if slightly redundant.