phpmysqldatabase-designaccounting

MySQL table designing for an Accounting system


I am designing an online accounting system as a college project. I have the following transactions:

  1. Sales in cash $300
  2. Cash borrowed from Smith $250
  3. Electricity bill paid $50

enter image description here

I saw Double Entry Accounting in a Relational Database and designed a Transaction table (a minus sign means the amount is credited). Ids 1 and 2 belong to transaction 1, ids 3 and 4 belong to transaction 2, and so on.

How can I identify each row pair as a single transaction in MySQL database?

If the first transaction is selected there is no relationship between the two rows.


Solution

  • Drop the two-line design unless it's really necessary. Merge the rows, add a field to store whether it was cash, and use the amount value sign to show whether it was credited or debited.