当前位置:网站首页>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
边栏推荐
- 学习笔记12--路径-速度分解法之局部路径搜索
- How to clean up the lodash.memoize cache in the element-plus virtual table virtual-list component?
- 763.划分字母区间——之打开新世界
- TRACE32 - SNOOPer-based variable logging
- Efficient use of RecyclerView Section 3
- thread_local 变量的析构顺序
- Getting started with UnityShader (3) - Unity's Shader
- 深入浅出边缘云 | 4. 生命周期管理
- Deployment应用生命周期与Pod健康检查
- Nuget打包并上传教程
猜你喜欢
Ubantu专题5:设置静态ip地址
LeetCode二叉树系列——222.完全二叉树的节点个数
工程力学复习资料
AVH Deployment Practice (1) | Deploying the Flying Paddle Model on Arm Virtual Hardware
OpenCV测量物体的尺寸技能 get~
Excel quickly aligns the middle name of the table (two-word name and three-word name alignment)
RecyclerView的高效使用第一节
使用 Chainlink Keepers 实现智能合约函数的自动化执行
微信聊天记录中搜索红包
11 pinia使用
随机推荐
自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统
Deployment应用生命周期与Pod健康检查
公告
Excel quickly aligns the middle name of the table (two-word name and three-word name alignment)
RecyclerView高效使用第二节
模板与泛型编程值typelist实现
SIGABRT 报错时的注意事项和解决方法
Advanced Mathematics - Commonly Used Indefinite Integral Formulas
JVM参数解析 Xmx、Xms、Xmn、NewRatio、SurvivorRatio、PermSize、PrintGC「建议收藏」
基于最小二乘法和SVM从天气预报中预测太阳能发电量(Matlab代码实现)
双边滤波加速「建议收藏」
TextBlock控件入门基础工具使用用法,取上法入门
Message queue data storage MySQL table design
charles进行弱网测试(app弱网测试怎么做)
svn安装及使用(身体功能手册)
Female service community product design
AVH Deployment Practice (1) | Deploying the Flying Paddle Model on Arm Virtual Hardware
Synchronized和volatile 面试简单汇总
Efficient use of RecyclerView Section 3
LeetCode二叉树系列——222.完全二叉树的节点个数