当前位置:网站首页>The normal form of the database (first normal form, second normal form, third normal form, BCNF normal form) "recommended collection"
The normal form of the database (first normal form, second normal form, third normal form, BCNF normal form) "recommended collection"
2022-07-31 15:12:00 【Full stack programmer webmaster】
Hello everyone, meet again, I'm your friend Quanstack Jun.
Before we understand the paradigm, let's understand DatabaseThe concept of code in the library
1.Code
1.1 Oversize
It can uniquely identify an attribute or attribute group of a tuple. Any superset containing a supercode is also a supercode. Here, the unique identification tuple can be simply understood as querying the value of a certain field or several fields.A specific row of data
1.2 Candidate code
The smallest code selected from the supercode, that is, any proper subset of it cannot satisfy the condition.That is, attributes cannot be deleted.
1.3 Master Code
Select one of the candidate codes as the primary code.
2. Normal Form (NF)
Paradigm: A collection of relational schemas that conform to a certain level, in short, as far as the standard level of database table design is concerned, the paradigms are 1NF, 2NF, 3NF, BCNF, 4NF, etc., usually highHigh-level paradigms contain low-level paradigms.The design of the database is generally BCNF, and sometimes it is necessary for performance.
2.1 1 Normal Form (1NF)
1 Normal Form: The attributes of the tables in the relationship are not separable. For a simple example, there is a student table with the following fields, sid, sname, address, sid is the primary key, sname is the student's name, address is the address, and the address data may include provinces, cities, streets, etc.of.In the future, we may need to count the number of students in a city separately, and combine so much information into one attribute, that is, it does not conform to the first normal form, and the attribute should be divided into multiple fields such as province and city to meet business requirements.
2.2 2 Normal Form (2NF)
2 Normal Form: Eliminate partial functional dependencies of non-primary attributes on codes.Functional dependence: Simply put, if for each x attribute or attribute group there is a corresponding exact y value corresponding to it, the Y function is said to be dependent on x.Write x->y complete functional dependence: there is x->y, but there is no x'->y for any proper subset of x, which is called complete functional dependence.For example, there is a grade sheet with several fields, student ID, course, grade.(student number, course) -> grade, any (student number)!-> grades, (course)!-" grade, we call grade completely dependent on (student number, course) partial functional dependency: the Y function does not fully depend on x is called partial functional dependency, for example (student number, course) -> course name), the student ID has nothing to do with the course name, i.e. (course) -> course name.
2.3 3 Normal Form (3NF)
3 normal form: Eliminate the transfer function dependence of non-primary attribute pairs of codesTransfer function dependence: A relation R(U), X, Y, Z are subsets on the attribute set U, which existsX→Y and Y→Z, but Y does not determine X, that is, Y!->X and Y does not contain Z, then there is X→Z, that is, the X transfer function determines Z, and the Z transfer function depends on X.For example: commodity table: commodity name -> warehouse, warehouse!-> Commodities, warehouses -> warehouse administrators, warehouse administrators !-> warehouses (assuming a warehouse can have multiple administrators).
2.4 BCNF Normal Form (BCNF)
BCNF paradigm: Eliminate indirect functional dependencies and transfer functional dependencies between primary attributes.
3.Summary
Generally, our database design can be in 3 normal form or BCNF normal form, but in practical projects, there is always a trade-off between performance and scalability.The higher the database design standard, the better the scalability and the lower the coupling, but the performance also suffers.Therefore, sometimes it will come to 2 paradigms. In order to reduce the association between tables and speed up the query speed, various advantages and disadvantages need to be weighed by themselves.
Publisher: Full-stack programmer, please indicate the source: https://javaforall.cn/128339.htmlOriginal link: https://javaforall.cn
边栏推荐
- 最小费用最大流问题详解
- Why don't you make a confession during the graduation season?
- 思路迪医药冲刺港股:5个月亏2.9亿 泰格医药与先声药业是股东
- Ubantu project 4: xshell, XFTP connected the virtual machine and set xshell copy and paste the shortcut
- SQL、HQL、JPQL 到底有什么区别
- 双边滤波加速「建议收藏」
- Efficient use of RecyclerView Section 2
- OpenShift 4 - Customize RHACS security policies to prevent production clusters from using high-risk registry
- R language test whether the sample conforms to normality (test whether the sample comes from a normally distributed population): shapiro.test function tests whether the sample conforms to the normal d
- Selenium自动化中无头浏览器的应用
猜你喜欢
随机推荐
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
Message queue data storage MySQL table design
[CUDA study notes] First acquaintance with CUDA
Linux查看redis版本(查看mongodb版本)
svn安装及使用(身体功能手册)
自适应控制——仿真实验二 用Narendra方案设计模型参考自适应系统
TRACE32——常用操作
element-plus虚拟表格virtual-list组件中是怎么实现清理lodash.memoize缓存的?
为什么黑客领域几乎一片男生?
Destruction order of thread_local variables
DeepLab Series Learning
高等数学——常用不定积分公式
11 pinia使用
工程力学复习资料
ES6 类
Getting started with UnityShader (3) - Unity's Shader
TRACE32——基于SNOOPer的变量记录
做事软件开发-法的重要性所在以及合理结论的认识
易驱线主控芯片对比(电动三轮电机90O瓦世纪通达)
Groupid(artifact id)