Currently, the mainstream databases we use are relational databases, so I am recording some understanding and views on the paradigm in relational databases. Database paradigm is divided into six types (in fact there is a BCNF), from the first paradigm to the sixth paradigm. The high-level layer is based on all the lower layers. For example, the 2nd paradigm is based on the first paradigm.
Currently, the mainstream databases we use are relational databases, so I am recording some understanding and views on the paradigm in relational databases. Database paradigm is divided into six types (in fact there is a BCNF), from the first paradigm to the sixth paradigm. The high-level layer is based on all the lower layers. For example, the 2nd paradigm is based on the first paradigm.
Currently, the mainstream databases we use are relational databases, so I am recording some understanding and views on the paradigm in relational databases. Database paradigm is divided into six types (in fact there is a BCNF), from the first paradigm to the sixth paradigm. The high-level layer is based on all the lower layers, for example, the 2nd paradigm is based on the first paradigm, and so on. The following examples illustrate various paradigms:
- 1NF)
The core description of the first paradigm is that each column in the database table is an inseparable basic data item, and there cannot be multiple values in the same column. This paradigm is about the atomicity of columns. There are two meanings: one layer means that each column can only store one attribute value (if two attribute values exist in one column ). The second layer indicates that the attribute values in a table cannot be repeated. In modern relational database services, the first paradigm is satisfied by default. Therefore, it is still impossible for you to write a structure that does not satisfy the first paradigm. If you want to dive deeper, you can study other non-relational databases.
- 2NF)
The core description of the second paradigm is: the row has a unique primary key, and the non-primary key only depends on the primary key. It is easy to understand that, at the first layer, each row must have a primary key (separate information or combined information. The second layer indicates that the primary key is not dependent on the primary key. If the primary key is a compound primary key, the non-primary key attribute cannot depend on some primary key attributes. For example, [product, Warehouse number, quantity, warehouse address, and Warehouse administrator]. Here (product + Warehouse Number) is a composite primary key, and the warehouse address and Warehouse administrator depend on the Warehouse number, this is the "primary key attributes cannot depend on some primary key attributes" described above. Therefore, this is against the second paradigm. The design that complies with the paradigm should be: [product, Warehouse number, quantity ], [repository No., repository address, and repository administrator ].
- 3NF)
The core description of the third paradigm is that non-primary key attributes do not depend on each other. This is easy to understand. For example: [student ID, name, Department number, department office location, department office phone number]. Here student ID is the primary key. The non-primary key attribute here is the number> Department Office + department office phone number. Here, we should split the table into two tables and connect the Foreign keys. The design should be: [student ID, name, Department number] and [Department number, department office location, department office phone number ].
The BC Paradigm (BCNF) is summed up by two defendants, Raymond F. Boyce and Edgar F. Codd. their surnames are spelled as the paradigm names. The BC paradigm is an enhanced version of the third paradigm.
- 4NF)
The core description of the fourth paradigm is that redundant multi-to-many relationships are not allowed. The core idea of this paradigm is to save database space. For example, [employee, skill, language], an employee can have multiple skills and multi-language skills, and one skill or language can be mastered by multiple employees. In this case, according to the fourth paradigm, we should design the form into [employee, skill] + [employee, language ]. During storage, we can save some space, but during operation, join often brings more system expenses.
- 5NF)
The fifth paradigm means to continue to break the data table if possible. The idea of this paradigm is the same as that of the fourth paradigm. We hope to eliminate redundancy and continue breaking information whenever possible. For example, in the preceding example, for a three-column table, if the columns in the table are multiple-to-many relationships between the two, three tables should be created according to the idea of the fifth paradigm, each table has two columns of the previous table.
- Sixth Paradigm (6NF)
The sixth paradigm is already extreme. According to the document, it is necessary to use it only when the data volume reaches the Data Warehouse level. It seems that the dependency and join relationship of the form are carefully designed, so we will not study it carefully.
When designing databases, the database design that meets the requirements of the paradigm is clearly structured, while avoiding data redundancy and operational exceptions. In general, it is OK to satisfy the second and third paradigms (the first paradigm is satisfied by default), which means that design that does not meet the requirements of the paradigm must be wrong. In this special case, rather than conforming to the requirements of the paradigm, it is reasonable.