当前位置:网站首页>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 :
边栏推荐
- 2022 National Games RE1 baby_ tree
- 2年经验总结,告诉你如何做好项目管理
- MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
- [algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
- Record: Navicat premium can't connect to MySQL for the first time
- 4.30 dynamic memory allocation notes
- 图书管理系统小练习
- Wechat applet development experience
- [算法] 剑指offer2 golang 面试题2:二进制加法
- The earth revolves around the sun
猜你喜欢
[Chongqing Guangdong education] Shandong University College Physics reference materials
Chromatic judgement bipartite graph
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和
[算法] 剑指offer2 golang 面试题1:整数除法
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和
MySQL shutdown is slow
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
How to ensure data consistency between MySQL and redis?
随机推荐
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
GNSS positioning accuracy index calculation
[算法] 剑指offer2 golang 面试题10:和为k的子数组
平衡二叉树详解 通俗易懂
2022 National Games RE1 baby_ tree
Shortest Hamilton path (pressure DP)
[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
First acquaintance with C language (Part 2)
错误:排序与角标越界
Alibaba cloud microservices (II) distributed service configuration center and Nacos usage scenarios and implementation introduction
Problems and solutions of robust estimation in rtklib single point location spp
TYUT太原理工大学2022软工导论考试题型大纲
Introduction pointer notes
Pride-pppar source code analysis
Itext 7 生成PDF总结
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
Record: I accidentally wrote a recursion next time
Tyut Taiyuan University of technology 2022 introduction to software engineering
Basic DOS commands
Application architecture of large live broadcast platform