当前位置:网站首页>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
边栏推荐
- 安装Xshell并使用其进行Ymodem协议的串口传输
- JVM参数解析 Xmx、Xms、Xmn、NewRatio、SurvivorRatio、PermSize、PrintGC「建议收藏」
- Trigonometric identity transformation formula
- How to clean up the lodash.memoize cache in the element-plus virtual table virtual-list component?
- RecyclerView高效使用第三节
- 11 pinia使用
- Message queue data storage MySQL table design
- TRACE32 - SNOOPer-based variable logging
- How useful is four-quadrant time management?
- 梅克尔工作室-第一次
猜你喜欢

LeetCode二叉树系列——226.翻转二叉树

基于最小二乘法和SVM从天气预报中预测太阳能发电量(Matlab代码实现)

Architecture actual combat battalion module 8 message queue table structure design

使用 Chainlink Keepers 实现智能合约函数的自动化执行

定时器的类型

RecyclerView的高效使用第一节

消息队列消息数据存储MySQL表设计

WeChat chat record search in a red envelope

Prometheus之node_exporter性能监控信息采集含义

Message queue data storage MySQL table design
随机推荐
实现防抖与节流函数
PDF 拆分/合并
工程水文学试卷
11 pinia使用
button控件的使用
TRACE32 - SNOOPer-based variable logging
Small test knife: Go reflection helped me convert Excel to Struct
01 邂逅typescript,环境搭建
微信聊天记录中搜索红包
TRACE32 - Common Operations
Nuget打包并上传教程
SIGABRT 报错时的注意事项和解决方法
国内市场上的BI软件,到底有啥区别
The role of /etc/profile, /etc/bashrc, ~/.bash_profile, ~/.bashrc files
为什么黑客领域几乎一片男生?
Node实现数据加密
Codeforces Round #796 (Div. 2)(A-D)
为什么毕业季不要表白?
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
DeepLab Series Learning