Question: What is paradigmatic design and why is de-normalized design needed?
Normal From EnglishNormal From
. In order to design a good database logical relationship during the development process, certain constraints must be met. This constraint forms a development paradigm, which is divided into several levels, with each level being stricter than the previous level.
Meeting these paradigms can theoretically make our database logical structure more concise and clear.
The following are the four common normal forms:
First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
Fourth Normal Form (BCNF)
Each column is an attribute value that cannot be subdivided, ensuring the atomicity of each column;
The attributes of the two columns are close or similar or the same. Try to merge columns with the same attributes to ensure that no redundant data is generated;
The columns with a single attribute are composed of basic data types;
The tables designed are all simple two-dimensional tables.
Example: User shipping address Counter example:
Name | Phone | Address |
---|---|---|
张三 | 138000000 | Beijing-Chaoyang District-Jiuxianqiao Street |
Positive example:
Phone number | province | city | 区 | 街 | |
---|---|---|---|---|---|
138000000 | - | Beijing City | Chaoyang District | Jiuxianqiao Street |
Summary: Each column is Atomic values that cannot be subdivided (a column cannot be subdivided, such as mailing address and province, city, district)
2. Second normal form (2NF)Counter example:
User ID | Product name | User name | Purchase quantity | Order time | |
---|---|---|---|---|---|
1 | Microwave oven A102 | 王马子 | 1 | 2022-08-08 |
Order form
User ID | Purchase quantity | Order time | |
---|---|---|---|
1 | 1 | 2022-08-08 |
Product Name | |
---|---|
Microwave oven A102 |
User name | |
---|---|
王 Mazi |
3. Third normal form (3NF)
ProductID | Product Name | Product Manufacturer | 1 | |
---|---|---|---|---|
100 | Microwave oven A102 | Midea | 2 | |
200 | Inverter air conditioner B101 | Haier |
Product ID | 1 | |
---|---|---|
##100 | 2 | |
200 | Product information sheet |
Product manufacturer | 100 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Midea | 200 | ||||||||||||||||||||||||||||||
Haier |
Summary: Eliminate the transitive dependence of fields on non-primary keys (that is, you need to cancel redundant information such as product name, product address, etc. in the order). 2. Normalized designIn terms of the definition of real database specifications, it is very rigorous. For example, the definition of second normal form (2NF) "If a certain relationship R term first normal form , and each non-primary attribute is completely functionally dependent on the candidate code, then the relation R belongs to the second normal form." The best design is not a design that strictly follows standardized theory, but the most suitable design solution that can be continuously practiced and summarized based on specific business scenarios. 3. Anti-standardization designThe so-called anti-standardization design is aimed at standardization. 1. Properly violate the requirements for database paradigm design for the sake of performance and reading efficiency; 3. For the sake of query performance, some (a small amount) of redundant data is allowed to exist. In other words, denormalized design is to directly trade space for time.
|
The above is the detailed content of MySQL database paradigm design method. For more information, please follow other related articles on the PHP Chinese website!