当前位置:网站首页>浅谈数据库设计之三大范式
浅谈数据库设计之三大范式
2022-04-23 20:39:00 【小简(JanYork)】
我的博客
https://www.ideaopen.cn/
范式?
即规范!
*范式是“符合某一种级别的关系模式的集合,表示一个关系内部各属性之间的联系的合理化程度”。 *很晦涩吧?实际上你可以把它粗略地理解为一张数据表的表结构所符合的某种设计标准的级别。
数据库范式也分为1NF,2NF,3NF,BCNF,4NF,5N
一般在我们设计关系型数据库的时候,最多考虑到BCNF
就够。
符合高一级范式的设计,必定符合低一级范式,例如符合
2NF
的关系模式,必定符合1NF
。
1NF
-第一范式
数据表的每一列都要保持它的原子特性,也就是列不能再被分割。
比如这样:
进货它还可以被分出进货的数量,进货的单价等等属性。所以这样是不符合第一范式的。
2NF
-第二范式
第二范式(
2NF
)是在第一范式(1NF
)的基础上建立起来的,即满足第二范式(2NF
)必须先满足第一范式(1NF
)。
- 即满足第一范式前提,当存在多个主键的时候,才会发生不符合第二范式的情况!!!。
- 比如有两个主键,不能存在这样的属性,它只依赖于其中一个主键,这就是不符合第二范式。
- 通俗理解是任意一个字段都只依赖表中的同一个字段。
依赖
在数据表中,属性(属性组)X确定的情况下,能完全退出来属性Y完全依赖于X。
完全依赖
完全依赖是针对于属性组来说,当一组属性X能推出来Y的时候就说Y完全依赖于X。
部分依赖
一组属性X中的其中一个或几个属性能推出Y就说Y部分依赖于X。
3NF
-第三范式
首先,要满足第三范式(3NF
)必须先满足第二范式(2NF
)。
也就是说,要求一个数据库表中不包含已在其它表中已包含的非主键字段。
三范式一定需要?
我们的三范式是一般规范。就是说,只是一般都会遵守这个规范。
但是!!!不是一定需要遵守,比如有时候,数据不冗余也不是好事。所以,我们要根据需要来定义,建立在需求之上。
没有冗余的数据库未必是最好的数据库,有时为了提高运行效率,提高读性能,就必须降低范式标准,适当保留冗余数据。
其他范式
BCNF
-BC范式
关系模式R<U,F>中,若每一个决定因素都包含码,则R<U,F>属于BCFN
。
即:
- 所有非主属性对每一个码都是完全函数依赖;
- 所有主属性对每一个不包含它的码也是完全函数依赖;
- 没有任何属性完全函数依赖于非码的任何一组属性。
4NF
-第四范式
限制关系模式的属性之间不允许有非平凡且非函数依赖的多值依赖。
5NF
-第五范式
- 必须满足第四范式。
- 表必须可以分解为较小的表,除非那些表在逻辑上拥有与原始表相同的主键。
一般在我们设计关系型数据库的时候,最多考虑到
BCNF
就够。!!!
版权声明
本文为[小简(JanYork)]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_60750453/article/details/124304928
边栏推荐
- JS arrow function user and processing method of converting arrow function into ordinary function
- Create vs project with MATLAB
- An error occurs when the addressable assets system project is packaged. Runtimedata is null
- The problem of 1 pixel border on the mobile terminal
- Solve the Chinese garbled code of URL in JS - decoding
- [PTA] l1-006 continuity factor
- Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
- Experience of mathematical modeling in 18 year research competition
- Common form verification
- Customize timeline component styles
猜你喜欢
LeetCode 74、搜索二维矩阵
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
Vulnhub DC: 1 penetration notes
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
Summary and effect analysis of methods for calculating binocular parallax
DOS command of Intranet penetration
[matlab 2016 use mex command to find editor visual studio 2019]
居家第二十三天的午饭
BMP JPEG 图片转换为矢量图像 ContourTrace
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
随机推荐
Recommend an open source free drawing software draw IO exportable vector graph
Matlab matrix index problem
启牛学堂有用吗,推荐的证券账户是否安全
MySQL 存储过程和函数
Identification of bolt points in aerial photography based on perception
Devexpress 14.1 installation record
"Meta function" of tidb 6.0: what is placement rules in SQL?
Scrapy教程 - (2)寫一個簡單爬蟲
LeetCode 994、腐烂的橘子
RT-1052学习笔记 - GPIO架构分析
Awk print special characters
【PTA】整除光棍
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
【PTA】L2-011 玩转二叉树
Leetcode 1351. Negative numbers in statistical ordered matrices
[PTA] l1-006 continuity factor
How to do after winning the new debt? Is it safe to open an account online
2021-06-29 C escape character cancellation and use
Introduction to standardization, regularization and normalization
UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value