Understanding the three paradigms of databases and the database paradigm
Database three paradigm understanding
1NF ):The first paradigm (1NF) means that each column in the database table is an inseparable basic data item. The same Column cannot contain multiple values, that is, an attribute in an object cannot have multiple values or duplicate attributes. In any relational database, the first paradigm (1NF) is the basic requirement for the relational model. databases that do not meet the first paradigm (1NF) are not relational databases.
Understanding notes:The column cannot be divided or understood as atomic.
2NF ):Before understanding 2NF, what isPrimary key combinationWhen the uniqueness of a field cannot be determined, other fields are required to form the uniqueness together. That is to say, if multiple fields are used to form uniqueness, they are combined with primary keys.
For example
Student Score (student ID, course number, score)
The student ID and course number can be used as the joint primary key.
Because the student ID and course number determine the score. That is to say. If you want to know the score, you need to know the student ID and student ID, but you still cannot know the score of a certain subject. You also need to know the course number.
The second Paradigm (2NF) is established on the basis of the first paradigm (1NF), that is, to satisfy the second Paradigm (2NF) must satisfy the first paradigm (1NF) first ). The second Paradigm (2NF) requires that each instance or row in the database table be uniquely distinguished. To implement differentiation, you usually need to add a column to the table to store the unique identifier of each instance, that is, the primary key. It is required that the attribute of an object fully depends on the primary key keyword. The second paradigm mainly aims to prevent other non-primary key fields from being partially dependent when a table has a composite primary key. For example:
Student Score (student ID, course number, course name, course score)
The course score is determined by the primary key student ID and course number of the primary key combination, but the course name is only determined by the course number, which violates the second paradigm.
Understanding notes:It cannot be partially dependent.
3NF ):The third paradigm (3NF) must satisfy the second Paradigm (2NF) first ). 3NF requires that all fields in a database table depend on the primary key. On the basis of the second paradigm, if the data table does not have a function dependency on any candidate keyword segment without a non-Keyword segment, it complies with the third paradigm. The so-called pass function dependency refers to the existence of "A → B → C" decision relationship, then the C transfer function depends on. For example:
Student table (student ID, Student name, school, college phone number)
The College telephone is dependent on the school, and the school relies on student information. Therefore, there is a dependency between the College telephone and student information. Therefore, the third paradigm is not satisfied.
Understanding Note: dependencies cannot be transmitted. That is, other fields except the primary key must depend on the primary key.
Additional:
Whether to create a table.
If the relationship between the two tables is many-to-many, you need to create a table. If the relationship between the two tables is multi-to-one or one-to-many, you can use the primary and Foreign keys to connect the two tables. You do not need to create an intermediate table.