Lets say a student enrolled in a particular course. His total fee is $25000 (base on other computations such as tuition fee, miscellaneous fees, etc.).
Now, this is what confuses me.
How can I get AND compute the total remaining balance of the student. Should I:
-
Subtract the amount he paid from his total balance(a column in my table) every time he pays.
-
Do not ever modify any column, but use another attribute called total_fee column. Just get the total amount he paid from every transactions that can be found in my tution_payment table, and then subtract the result from the total_fee(this can be done through my query). Also please be noted that I didnt use total_balance here.
I remember someone told me that
Financial transactions are generally only inserted
Does this mean that my former solution is right? Currently, I use the latter, but feels that it is an inaccurate solution.
I am not familiar with how databases represent accounting transactions, so any help will be much appreciated.
Normally, there would be a table with transactions. The student fee would be booked as credit to the university and debit to the student. A repayment would be booked as credit to the student. An interest fee would be credit to the university.
That way, there is no need to store a balance. You calculate the balance based on the transaction history. The biggest advantage is that you can explain the balance; it’s not just a number stored in a database, but it has a full history of how it came to be.