当前位置:网站首页>Three paradigms of database design
Three paradigms of database design
2022-07-04 08:14:00 【Vivien_ oO0】
brief introduction
In order to establish less redundancy , A well structured database , Certain rules must be observed when designing the database , In relational databases, this rule is the paradigm . A paradigm is a collection of relational patterns that conform to a certain level . The relationship in relational database must meet certain requirements , That is to meet different paradigms .
At present, there are six paradigms in relational database , Generally speaking, as long as the database meets the third paradigm , And what we often use is what we call the three paradigms , First normal form , Second and third paradigms .
First normal form
Atomicity 、 Indivisibility
What does that mean ?
It requires that every field in your table cannot be further split , Are the smallest data units .
If there is the following student information form
Student information sheet
| Student number | full name | Home address | College number | The name of the College | Dormitory number | Dormitory type | The number of beds in the dormitory |
|---|---|---|---|---|---|---|---|
| 001 | Zhang San | Xi'an, Shaanxi Province | 100001 | College of science | 222 | standard room | 4 |
| 002 | Li Si | Xianyang City, Shaanxi Province | 100002 | school of computing | 333 | Non standard room | 6 |
| 003 | Wang Wu | Baoji City, Shaanxi Province | 100003 | School of Marxism | 666 | standard room | 4 |
The address column can be further split into provinces 、 City So this table does not conform to the first normal form
Second normal form
Second normal form It is required that on the premise of ensuring the first paradigm , requirement Each column should be related to the primary key , It cannot only be related to a part of the primary key , Require entity uniqueness .
For example, the following table :
| Student number | full name | College number | The name of the College | Dormitory number | Dormitory type | The number of beds in the dormitory |
|---|---|---|---|---|---|---|
| 001 | Zhang San | 100001 | College of science | 222 | standard room | 4 |
| 002 | Li Si | 100002 | school of computing | 333 | Non standard room | 6 |
| 003 | Wang Wu | 100003 | School of Marxism | 666 | standard room | 4 |
The primary key is student number, college number and dormitory number
full name 、–> Student number
The name of the College —> College number
Dormitory type 、 The number of beds in the dormitory —> Dormitory number
The above is only partially dependent So it violates the second paradigm So you should split the table
| Student number | full name | College number | Dormitory number |
|---|---|---|---|
| 001 | Zhang San | 100001 | 222 |
| 002 | Li Si | 100002 | 333 |
| 003 | Wang Wu | 100003 | 666 |
| College number | The name of the College |
|---|---|
| 100001 | College of science |
| 100002 | school of computing |
| 100003 | School of Marxism |
| Dormitory number | Dormitory type | The number of beds in the dormitory |
|---|---|---|
| 222 | standard room | 4 |
| 333 | Non standard room | 6 |
| 666 | standard room | 4 |
The primary key of the first table is student number , The primary key of the second table is the college number , The primary key of the table in Chapter 3 is dormitory number
This design makes the database clearer , If you need to find the name of the College , Check directly in the college table
Third normal form
The third paradigm requires Each column is directly related to the primary key column Not indirectly , That is, limit the redundancy of columns
.
| Dormitory number | Dormitory type | The number of beds in the dormitory |
|---|---|---|
| 222 | standard room | 4 |
| 333 | Non standard room | 6 |
| 666 | standard room | 4 |
Like the above table . Dormitory number —> Dormitory type —> The number of beds in the dormitory
From these dependencies, we can choose the dormitory number —> The number of beds in the dormitory
Dormitory No —> The number of beds in the dormitory is called transmission dependence
So the table should be subdivided again
| Dormitory number | Dormitory type |
|---|---|
| 222 | standard room |
| 333 | Non standard room |
| 666 | standard room |
| Dormitory type | The number of beds in the dormitory |
|---|---|
| standard room | 4 |
| Non standard room | 6 |
| standard room | 4 |
In this way, there is no indirect dependency .
Be careful : The repeated occurrence of primary keys and foreign keys in multiple tables does not belong to data redundancy , The repetition of non key fields is data redundancy .
边栏推荐
- PHP converts seconds to timestamps - PHP
- 广和通高性能4G/5G无线模组解决方案全面推动高效、低碳智能电网
- Add log file to slim frame - PHP
- Activiti常見操作數據錶關系
- Figure guessing game
- What determines vacuum permittivity and vacuum permeability? Why do these two physical quantities exist?
- [CV] Wu Enda machine learning course notes | Chapter 9
- Linear algebra 1.1
- How to write a summary of the work to promote the implementation of OKR?
- If the array values match each other, shuffle again - PHP
猜你喜欢

Introduction to neural network (Part 2)

DM8 tablespace backup and recovery

Ecole bio rushes to the scientific innovation board: the annual revenue is 330million. Honghui fund and Temasek are shareholders

snipaste 方便的截图软件,可以复制在屏幕上

L2-013 red alarm (C language) and relevant knowledge of parallel search

Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future
![[go basics] 2 - go basic sentences](/img/b1/961615b439d75679a3bb40a60f208d.png)
[go basics] 2 - go basic sentences

如何用MOS管来实现电源防反接电路

JVM -- class loading process and runtime data area

Comprendre la méthode de détection des valeurs aberrantes des données
随机推荐
Take you to master the formatter of visual studio code
C # implements a queue in which everything can be sorted
Unity write word
L1-026 I love gplt (5 points)
Group programming ladder race - exercise set l1-006 continuity factor
zabbix監控系統自定義監控內容
Activiti常见操作数据表关系
[test de performance] lire jmeter
string. Format without decimal places will generate unexpected rounding - C #
Using the rate package for data mining
真空介电常数和真空磁导率究竟是由什么决定的?为何会存在这两个物理量?
Use preg_ Match extracts the string into the array between: & | people PHP
L2-013 red alarm (C language) and relevant knowledge of parallel search
[go basics] 1 - go go
[gurobi] establishment of simple model
Leetcode (215) -- the kth largest element in the array
Oracle stored procedures and functions
2022 gas examination registration and free gas examination questions
PHP session variable passed from form - PHP
Leetcode 146. LRU cache