当前位置:网站首页>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 :
边栏推荐
- Inheritance and polymorphism (I)
- 121 distributed interview questions and answers
- 2年经验总结,告诉你如何做好项目管理
- How do architects draw system architecture blueprints?
- 继承和多态(上)
- 2-year experience summary, tell you how to do a good job in project management
- [算法] 剑指offer2 golang 面试题2:二进制加法
- Employment of cashier [differential constraint]
- [算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
- IText 7 generate PDF summary
猜你喜欢
随机推荐
[算法] 剑指offer2 golang 面试题2:二进制加法
平衡二叉树详解 通俗易懂
Alibaba cloud microservices (III) sentinel open source flow control fuse degradation component
【快趁你舍友打游戏,来看道题吧】
Record: the solution of MySQL denial of access when CMD starts for the first time
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
错误: 找不到符号
[Chongqing Guangdong education] Shandong University College Physics reference materials
Fundamentals of UD decomposition of KF UD decomposition [1]
Exception: ioexception:stream closed
Design a key value cache to save the results of the most recent Web server queries
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
记录:newInstance()过时的代替方法
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
[rtklib] preliminary practice of using robust adaptive Kalman filter under RTK
初识指针笔记
Usage differences between isempty and isblank
TYUT太原理工大学2022数据库题库选择题总结
【无标题】
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和