当前位置:网站首页>Decomposition relation model of the 2022 database of tyut Taiyuan University of Technology
Decomposition relation model of the 2022 database of tyut Taiyuan University of Technology
2022-07-06 13:12:00 【Lala Lulu^_^】
Question 4
Decompose relational patterns : Examination site : Basic functional dependencies of relational patterns 、 Relationship candidate key 、 Which paradigm does relationship belong to 、
What kind of relationship does it belong to NF、 decompose NF Pattern set (10 branch )
To master this topic, we must first master many basic concepts , Let's have a look , Just talk about what you want to test and what you will use to do the questions 、 I won't talk about the official words in the book , How to understand how to
One 、 Basic concepts
1、 Function dependency (FD): Functional dependency is the constraint relationship between attributes within the same relationship , That is to say R(A1,A2...) Medium lecture A1 And A2 And so on , For example, set the attribute student number to X、 The name is Y, Because the student number can decide the name , Then there are X decision Y Or say Y Depend on X, Write it down as :X->Y
2、FD Set ( Functional dependency set ): Will be multiple FD Put them together : Such as function dependency set F={A->B,B->C,A->C}, If there is a set, there will be implication , therefore F Logic implies X->Y, Write it down as :F|=X->Y
3、 Super key : Set a relationship R The property set of is U,X yes U Subset , If U Some of the properties in X Can decide U, namely X->U, So called X yes R A super key of ( Remove any attribute in the hyperkey ,X->U Still possible )
4、 Candidate key : In hyperkeys , If you remove any attribute in the hyperkey ,X->U Will not be established ( That is, there is no redundant attribute in the super key ), Then call this super key a candidate key
5、L class :F={A->B,B->C,A->C} All in -> Properties on the left , namely A、B
6、R class :F={A->B,B->C,A->C} All in -> Properties on the right , namely B、C
7、 Minimum functional dependency : The difficult words , Pass the examination , But I haven't seen it in the past two years , It's the test site , If you want to learn, you can read by yourself , I won't talk about it here
8、 Decomposition of relational patterns : We can R(A1,A2,A3,A4) Decompose into R1(A1,A2),R2(A3,A4)
9、 Completely function dependent : There are attribute sets X And property sets Y, Functional dependency X->Y, Get rid of X Any attribute in ,X->Y It doesn't work ( That is the X There is no redundant attribute in ), that Y The complete function depends on X, Otherwise, it is called local dependency
10、 Non primary property : It refers to the attribute that is not included in any candidate code in the relationship . for example : In relation —— Student ( Student number , full name , Age , Gender , class ) in , Main attribute 、 The candidate code is “ Student number ”, So the others “ full name ”、“ Age ”、“ Gender ”、“ class ” Can be called non primary property
( Similar to determining candidate keys , It's all about dependencies L Whether the class has redundant attributes )
11、 The transitive dependency that will appear in the big question : There are candidate keys X、 Non primary property Y、A, if X->Y,Y->A,Y!->X,A Do not belong to Y, So called X->A It's delivery dependency (A Delivery depends on X)
Two 、 The paradigm of relationship pattern
There is an inclusive relationship between paradigms :1NF contain 2NF contain 3NF contain BCNF
1、 First normal form (1NF)
As long as the relationship mode R(A1,A2...) All properties in A1、A2...... Are inseparable attributes , Are atomic properties , Then meet the first paradigm
To be dissatisfied with 1NF Relationship model of R, We're going to R Become satisfied 1NF Relationship model of : Or decompose its non atomic properties , Or decompose its relationship pattern , You are satisfied with the general questions 1NF
2、 Second normal form (2NF)
If the relational pattern R yes 1NF, And each non primary attribute is completely functionally dependent on candidate keys , be R For the second paradigm (2NF)
Judge whether it is 2NF: Put the candidate key ( The common candidate keys in big questions generally include 2 Attributes ) Determine each non primary attribute in turn , Judge whether the function depends on the right (L class ) Whether there are redundant attributes , If there is no , It's in line with 2NF , On the contrary, it does not meet
To be dissatisfied with 2NF Relationship model of R, We're going to R Become satisfied 2NF Relationship model of : In fact, it is a simple classification , We put R Decompose into R1、R2....... Non primary attributes that will be redundant with candidate keys 、 And its corresponding candidate keys are placed in R1 in ; Non primary attributes that will not be redundant with candidate keys 、 And its corresponding candidate keys are placed in R2 in . Let's take an example to understand :
example : Set a relationship R( Customer number , The number of the item purchased , Number , Name of the manufacturer , Business address ), Judge R Whether to belong to 2NF, If R Do not belong to 2NF, Please put R Decompose into 2NF Pattern set
Explain : The candidate key is the customer number , The number of the item purchased , Yes ( Customer number , The number of the item purchased )->( Name of the manufacturer , Business address ), Because of a single attribute “ The number of the item purchased ” You can decide “ Name of the manufacturer , Business address ”, Therefore, there is a case that non primary attributes locally depend on candidate keys ,R Do not belong to 2NF
| take R Decompose into 2NF Pattern set thinking ( Don't write on the paper , Write only on scratch paper ) |
![]() |
take R Decompose into 2NF The pattern set is :
R1( The number of the item purchased , Name of the manufacturer , Business address )
R2( Customer number , The number of the item purchased , Number )
3、 Third normal form (3NF)
Brush up on :11、 The transitive dependency that will appear in the big question : There are candidate keys X、 Non primary property Y、A, if X->Y,Y->A,Y!->X,A Do not belong to Y, So called X->A It's delivery dependency (A Delivery depends on X)
If the relational pattern R yes 2NF, And each non primary attribute does not rely on candidate keys , be R For the third paradigm (3NF)
Judge whether it is 3NF: By definition , See if there is a phenomenon that non primary attribute transmission depends on candidate keys in the relational pattern .
To be dissatisfied with 3NF Relationship model of R, We're going to R Become satisfied 3NF Relationship model of :
If in R(X,Y,A,B,C) in , The candidate key is X、 Non primary attribute is Y、A、B、C, There is X->Y,Y->A,Y!->X,A Do not belong to Y( namely X->A,A Delivery depends on X), Then just put R Decompose into R1(X,Y,B,C),R2(Y,A) To satisfy 3NF, It can be understood as R1 Only the Y,R2 Only two non primary attributes that are transitively dependent on candidate keys are retained Y,A
Look at an example to understand
example : There's a relational model : readers ( Reader number , full name , Company , Address ), Each unit has only one address , Please normalize it into 3NF
Explain :
From the meaning of the question : Reader number -> Company -> Address
readers 1( Reader number , full name , Company ) Only the address at the end of the delivery position is removed
Company ( Company , Address ) Only two non primary attributes that are transitively dependent on candidate keys are retained : Company , Address
The real question :

边栏推荐
- KF UD decomposition pseudo code implementation advanced [2]
- Heap sort [handwritten small root heap]
- 架构师怎样绘制系统架构蓝图?
- [算法] 剑指offer2 golang 面试题10:和为k的子数组
- Abstract classes and interfaces
- 记录:初次cmd启动MySQL拒接访问之解决
- [rtklib 2.4.3 B34] version update introduction I
- [algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
- Problems and solutions of robust estimation in rtklib single point location spp
- 阿里云微服务(二) 分布式服务配置中心以及Nacos的使用场景及实现介绍
猜你喜欢
![[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数](/img/64/0f352232359c7d44f12b20a64c7bb4.png)
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数

Application architecture of large live broadcast platform

Dark chain lock (lca+ difference on tree)

一文搞定 UDP 和 TCP 高频面试题!

Novatel board oem617d configuration step record

十分钟彻底掌握缓存击穿、缓存穿透、缓存雪崩

平衡二叉树详解 通俗易懂
![[algorithm] sword finger offer2 golang interview question 10: subarray with sum K](/img/63/7422489d09a64ec9f0e79378761bf1.png)
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
![[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等](/img/11/ee0628a68542236fc641966579a31a.png)
[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等

Role movement in the first person perspective
随机推荐
国企秋招经验总结
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
Inheritance and polymorphism (I)
RTKLIB: demo5 b34f. 1 vs b33
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
TYUT太原理工大学2022数据库大题之概念模型设计
TYUT太原理工大学2022数据库大题之数据库操作
雇佣收银员【差分约束】
4.30 dynamic memory allocation notes
【无标题】
Design a key value cache to save the results of the most recent Web server queries
记录:newInstance()过时的代替方法
Realization of the code for calculating the mean square error of GPS Height Fitting
[算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
Error: symbol not found
How to ensure data consistency between MySQL and redis?
Fundamentals of UD decomposition of KF UD decomposition [1]
Fairygui bar subfamily (scroll bar, slider, progress bar)
