Get the App
SLTechnology News&Howtos  ›  Database  › 

Summary of database paradigm

Shulou Source: shulou.com Published: 2022-06-01 22:08:45 10月02日 Update

1NF: each column of a database table is an indivisible basic data item.

Analysis: there are no multiple columns that represent the same property; the value of a column cannot be a collection. It is almost impossible to represent an one-to-many relationship as multiple attributes of a table or multiple values of an attribute.

Solution: create a new table with "1" as the foreign key of the new table.

For example:

Person

Id

Name

Hobby1

Hobby1

Bobby3

one

Mark

Playing football

Running

Swimming

Or

Person

Id

Name

Hobbies

one

Mark

Playing football,running,awimming

2NF: conforms to 1NF; there is a primary key and there are no partial functional dependencies (there are no columns that depend on part of the primary key)

Analysis: in the case of combined keys, some columns depend on only part of the combined primary key, then it does not conform to 2NF.

Solution: move the columns that involve some functional dependencies out of the old table and save them in the new table. Or use artificial primary keys instead of key combinations.

For example:

Employee

Department

Name

ManagerOfDepartment

Development department

Mark

Jenny

3NF: conforms to 2NF; and there is no transitive dependency.

Analysis: column An in the same table depends on column B, and column B depends on column C.

Solution: move the columns involving transfer function dependencies out of the old table and save them in the new table.

For example:

Customer

Name

Phone

Address

ZipCode

Mark

1273283

Guangzhou × × ×

510000

Tags: Function multiple attribute analysis combination data part database indivisible labor situation data item department Guangzhou development paradigm Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Microsoft Apple Docker Huawei