当前位置:网站首页>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 .
边栏推荐
- 促进OKR落地的工作总结该如何写?
- The second session of the question swiping and punching activity -- solving the switching problem with recursion as the background (I)
- Need help resetting PHP counters - PHP
- 1. Getting started with QT
- Unity text superscript square representation +text judge whether the text is empty
- Go h*ck yourself:online reconnaissance (online reconnaissance)
- 1. Kalman filter - the best linear filter
- Is l1-029 too fat (5 points)
- DM database password policy and login restriction settings
- @Role of requestparam annotation
猜你喜欢

1、卡尔曼滤波-最佳的线性滤波器

Introduction to neural network (Part 2)

Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)

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

What sparks can applet container technology collide with IOT

Wechat has new functions, and the test is started again

SQL注入测试工具之Sqli-labs下载安装重置数据库报错解决办法之一(#0{main}thrown in D:\Software\phpstudy_pro\WWW\sqli-labs-……)

C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码

Linear algebra 1.1

BUUCTF(4)
随机推荐
学习Nuxt.js
Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
Do you know about autorl in intensive learning? A summary of articles written by more than ten scholars including Oxford University and Google
Sqli labs download, installation and reset of SQL injection test tool one of the solutions to the database error (# 0{main}throw in d:\software\phpstudy_pro\www\sqli labs-...)
L1-028 judging prime number (10 points)
Activiti常見操作數據錶關系
Leetcode 146. LRU 缓存
如何用MOS管来实现电源防反接电路
zabbix监控系统自定义监控内容
es6总结
Google's official response: we have not given up tensorflow and will develop side by side with Jax in the future
L2-013 red alarm (C language) and relevant knowledge of parallel search
This monitoring system can monitor the turnover intention and fishing all, and the product page has 404 after the dispute appears
Oracle-存储过程与函数
Group programming ladder race - exercise set l2-002 linked list de duplication
What does range mean in PHP
Moher College phpmailer remote command execution vulnerability tracing
Set and modify the page address bar icon favicon ico
Easy to understand: understand the time series database incluxdb
Go h*ck yourself:online reconnaissance (online reconnaissance)