Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
15.7k views
in Technique[技术] by (71.8m points)

MySQL, should a field be created to store the relational table calculation?

I know that:

No, you would never store a value that could be calculated from other columns in the database. Storing calculated values is a violation of database normalization.

But what about the calculated value from the relational table? For example, amount in orders is calculated from the order_products table with the formula sum (price * qty). Should I save this value in the orders table?. Thanks.

question from:https://stackoverflow.com/questions/66059496/mysql-should-a-field-be-created-to-store-the-relational-table-calculation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...