大家看这个表,其实主科总分,副科总分,总分 都能通过 前面的的数据算出来,
我想问问,要是 不考虑存储空间的情况下,
是把 主科总分,副科总分,总分 在插入数据的时候,就算出来好,
还是 用 VIEW 算好?
这个好的意思,是减少服务器负担,还是搜索速度快.
伊谢尔伦2017-04-17 14:56:56
From the perspective of the third paradigm, the three columns of main subject total score, secondary subject total score, and total score are data that depend on other columns and should not be placed in the database table as separate columns.
If you consider that the pressure of data reading is high and you don’t want to do calculations on the application server or database side, you can store it in the table as redundant columns. In the scenario mentioned above, the number of modifications to students' grades after they are entered should be very few. Therefore, the update cost of redundant columns is low. It is a typical situation of more reads and less writes. Therefore, there is overall pressure on the server due to redundant columns. will be lower.
迷茫2017-04-17 14:56:56
It depends on whether you insert a lot of data or read a lot of results;
When you insert a lot of data, put the calculation in the view, and when you read a lot of data, put the SQL calculation results in the table, but the reading pressure It is much lower than insertion. This ratio still needs to be weighed. It is recommended to choose to place it in the view.