1. Design Paradigm
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)
1. First normal form (1NF)
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)- The second normal form (2NF) is built on the basis of the first normal form.
- Second Normal Form (2NF) requires that the attributes of an entity are completely dependent on being associated with the primary key. The so-called completion dependency refers to the partial attributes that cannot exist and exist depending on the keyword. If they exist, then this attribute and the keyword part should be separated to form a new entity. The new entity has a one-to-many relationship with the original entity.
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)
- To satisfy the third normal form (3NF), the second normal form (2NF) must be satisfied.
- Third Normal Form (3NF) requires that a data table does not contain non-primary key keyword information that is already included in other tables, that is, the data cannot have a transitive relationship, that is, each attribute must be There is a direct relationship with the primary key rather than an indirect relationship.
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!

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.

MySQL is an efficient relational database management system suitable for storing and managing data. Its advantages include high-performance queries, flexible transaction processing and rich data types. In practical applications, MySQL is often used in e-commerce platforms, social networks and content management systems, but attention should be paid to performance optimization, data security and scalability.

The relationship between SQL and MySQL is the relationship between standard languages and specific implementations. 1.SQL is a standard language used to manage and operate relational databases, allowing data addition, deletion, modification and query. 2.MySQL is a specific database management system that uses SQL as its operating language and provides efficient data storage and management.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools