Should I store a calculate value in my database along with the variables?

前端 未结 5 824
囚心锁ツ
囚心锁ツ 2020-12-31 07:00

In all the applications I have made where a database is used I typically store the calculated value along with the variables needed to calculate that value. For example, if

5条回答
  •  北海茫月
    2020-12-31 07:33

    This violates Normal Form to have this calculated value. Unless there is a reason to denormalize (usually performance constraints) then you should make every attempt to normalize your tables, it will make your database much easier to maintain/improve and denormalize may lock you into a design that is difficult to alter easily and exposes your data to inconsistencies and redundancy.

提交回复
热议问题