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

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.
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.