SoFunction
Updated on 2024-10-30

Database The simplest and most memorable explanation of the three paradigms

There's a lot in the book, but it all boils down to three sentences:

1NF: Field is not separable.
2NF: There is a primary key, and non-primary key fields depend on the primary key.
3NF: Non-primary key fields cannot depend on each other.

Explanation.
1NF: Atomicity Fields cannot be subdivided, otherwise it is not a relational database.
2NF: Uniqueness A table describes only one thing.
3NF: each column is directly related to the primary key, no passing dependencies; the

Examples that do not conform to the first paradigm (such a table cannot be created in a relational database):

Table:Field 1, Field 2 (Field 2.1, Field 2.2), Field 3 ......

Problems: No problems because no such table can be designed.

Examples that do not fit the second paradigm.

Table:Student Number, Name, Age, Course Title, Grade, Credit.

This table clearly illustrates two transactions: student information, course information.

Problems.

Data redundancy, where each record contains the same information;
Delete anomaly: Deleting all student grades deletes all course information;
Insertion Exception: Student has not selected a course and cannot be recorded into the database;
Update Exception: adjusted course credits, all rows adjusted.

Amendment.

Student: Student(number, name, age);

Course: Course (course name, credits);

Selection relationship: SelectCourse(number, course name, grade).

Satisfying Paradigm 2 only eliminates the insertion exception.


Examples that do not fit the third paradigm.

Student number, name, age, faculty, faculty contact number, with a single keyword "student number".

Dependency transfer exists: (student number) → (college) → (college location, college phone)

Problems.

Data redundancy: there are duplicate values;

Update exception: there is duplicate redundant information, you need to modify multiple records at the same time when modifying, otherwise there will be data inconsistency

Delete Exception

Amendment:
Student: (number, name, age, college);
College: (College, Location, Phone).
Author:sunxing007