user's id, and the "order table" has a field --&"/> user's id, and the "order table" has a field --&">
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!