user's id, and the "order table" has a field --&"/> user's id, and the "order table" has a field --&">

Home  >  Article  >  Database  >  Understanding of database redundant fields and their appropriateness

Understanding of database redundant fields and their appropriateness

怪我咯
怪我咯Original
2017-06-23 13:41:272447browse


According to my personal understanding, redundant fields are fields that originally exist in one table and also appear in another table.

Recommended related mysql video tutorials: "mysql tutorial"

For example: there are three tables, user table, product table, order table, and the user table has the field name, The field name also exists in the order table.

There are good and bad aspects of redundancy in this field

Good:

Starting from the user table, product table, and order table, when I need Querying all the data of the "order table" and only requiring the name of the "user table" can generally be queried through a database connection (join).

For example, the "product table" has a field --> user's id, " "Order table" has a field --> product id. I can query all orders, query the corresponding products through the product id in the order, and then query the user name accordingly.

If there are more tables, such as 1,000 table ("a bit exaggerated, please understand"), in order to get the name in the user table, the speed of this query can be imagined.

At this time, add a field name to the order table, and directly query the order to complete the requirement, which is simple and clear.

Bad:

Same as above. At this time, if you add, delete or modify the user name field, you must also add, delete or modify the fields in the order table. At this time, you need to understand Redundant fields in all tables, in case fields in some tables are not modified accordingly.

In this case, depending on the needs, if the impact is not significant and it is beneficial to development efficiency, redundant fields can be added appropriately.

The above is the detailed content of Understanding of database redundant fields and their appropriateness. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn