Database redundancy fields and suitability, database redundancy Fields
In my personal opinion, a redundant field is a field that exists in one table and also appears in another table.
For example, there are three tables: User table, product table, and order table. The user table has a field name, and the order table also has a field name.
Good or bad for this field Redundancy
Good:
Starting from the user table, product table, and order table, when I want to query all the data in the "Order table" and only need the name of the "user table", the database connection is generally allowed) query,
For example, the "Product table" has a field --> User id, and the "Order table" has a field --> product id. I can query all orders and query the corresponding product by the product id in the order, then query the user name,
If there are more than one table, for example, 1000 tables ("a little exaggerated, please forgive me"), in order to get the name in a user table, the query speed can be imagined.
Add a field name to the order table, and query the order directly to complete the requirement, which is simple and clear.
Bad:
Same as above. In this case, you need to add, delete, and modify the User name field. In this case, you also need to know the redundant fields in all tables to prevent the fields in some tables from being modified.
To address this problem, we recommend that you add redundant fields if the impact is not significant and is conducive to development efficiency.
Note: This is the first time that Tom wrote a blog. Some examples may not meet the actual development requirements. Please forgive me.
Copyright Disclaimer: This article is an original article without code and cannot be reproduced without permission.