应用户的帐户余额存储在数据库中或动态计算的? [英] should the user's Account balance be stored in the database or calculated dynamically?
问题描述
如果用户的帐户余额存储在数据库中或动态计算的?
Should the user's Account balance be stored in the database or calculated dynamically?
有关准确的结果计算其动态意义,但那么它可能是一个问题,当有许多用户和数据库变得非常大?
For accurate results calculating it dynamically make sense but then it might be a problem, when there are many user's and the database grows very large?
交易
- ID(PK)
- ACCOUNTID
- 键入
- 日期时间
- 金额
- etc..etc ...
AccountBalance
AccountBalance
- TRANSACTIONID(PK / FK)
- BalanceAmount
推荐答案
为了保持准确审计,你应该尽一切影响用户的账户余额的交易记录。这意味着你可以计算出动态的平衡,但是,对于我会平衡存储以及性能方面的原因。为了保证平衡是正确的,虽然,我将有一个日常工作运行的重新计算从头平衡。
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.
这篇关于应用户的帐户余额存储在数据库中或动态计算的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!