Best way to maintain a customer's account balance

前端 未结 8 719
孤独总比滥情好
孤独总比滥情好 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条回答
  •  Happy的楠姐
    2021-02-06 11:09

    One project I worked on we stored the current balance in one field, and all the transactions on another table, but because of the level of importance that this project had on the data being perfect 100% (or better) or the time, we also stored a hash of the balance in another field and the hash was compared each time it was called to ensure integrity, it if did not match up it was recalculated from the transactions table, and re-hashed then sent to the customer support dept. for review.

提交回复
热议问题