mysql建表的规范和实际应用中的冲突问题。
PHP中文网
PHP中文网 2017-04-17 13:43:35
0
3
404

今天研究shopnc的数据表结构,发现很多表不按照三范式来建表,很多表都是相关字段重复。

优点是很多时候不用关联表进行查询了。

缺点是不按照三范式规范,而且如果中途改一个表的字段后,相应的表也应该进行修改,但到那个时候已然发现不好改了,因为可能涉及的表太多太多了。

所以我想直到怎么取舍这个问题。

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
Ty80

Performance is usually considered first. If a redundant field can reduce many related queries, then redundancy is usually chosen instead of pursuing the third normal form.
For example, the article details page usually has the number of comments. This number of comments is usually redundant in the article table, instead of being counted in the comment table every time.
But anti-paradigm also has disadvantages: more fields to maintain, data may be inconsistent, storage space is larger, etc.
It depends on whether you can use it flexibly

PHPzhong

Generally speaking, redundancy is necessary for performance;
As for what you said if a table value change affects redundant information, it is usually regulated through the product,
or redundant Information is not allowed to change in the defined table, such as the user name when you registered;
or redundant information will not be updated after the defined information is changed, such as the product title information saved on the order when you purchase the product and generate the order. .

巴扎黑

As mentioned above, we need to make trade-offs

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template