Best way to maintain a customer's account balance

前端 未结 8 742
孤独总比滥情好
孤独总比滥情好 2021-02-06 10:24

Is it better to have a field in the database that stores the customers account balance or use views and queries to generate the information.

8条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 11:10

    I think this depends on a lot of factors, how often will you be accessing the balance, how complex is it to recalculate it everytime you need it. What are the overheads of having views, etc.

    Purely on the face of the information you have given I would store the value as recalculating it from scratch each time could be a pain.

提交回复
热议问题