"should the user's account balance be stored in the database or calculated dynamically?" Code Answer
2
in order to keep accurate auditing you should make record of every transaction that affects the users account balance. this means you can calculate the balance dynamically, however for performance reasons i would have the balance stored as well. to ensure the balance is correct though, i would have a daily job run that recalculates the balance from scratch.
in order to keep accurate auditing you should make record of every transaction that affects the users account balance. this means you can calculate the balance dynamically, however for performance reasons i would have the balance stored as well. to ensure the balance is correct though, i would have a daily job run that recalculates the balance from scratch.