版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、COMP231 Tutorial 6Functional Dependencies and Normalization 2Review: We want to decompose SchemasDecompositionR=A,B,C,D,ER1=A,B,C, R2=D,ELossless-join decomposition (complete reproduction)Satisfy normal forms (BCNF or 3NF)Dependency preservingR = A,B,C,D,E. F = ABC, CD E, B D, EA .Is the following d
2、ecomposition a lossless join?1) R1 = A,B,C,R2 =A,D,E.2) R1 = A,B,C,R2 =C,D,E.1) Since R1 R2 = A, and A is a key for R1, the decomposition is lossless join.2)Since R1 R2 = C, and C is not a key for R1 or R2, the decomposition is not lossless join.Exercise 1: Lossless-join DecompositionR = A,B,C,D,E.F
3、 = ABC, CD E, B D, EA .R1 = A,B,C, R2 = A,D,E.Is the above decomposition dependency-preserving?No.CD E and B D are lost. Exercise 2 : FD-Preserving DecompositionBCNF: R is in BCNF if and only iffor each FD: X A in F+ThenA X (trivial FD), orX is a superkey for R In other words, the left part of any n
4、on-trivial dependency must be a superkey.* If we do not have redundancy in F, then for each X A , X must be a candidate key.* The decomposition is lossless-join but may not be dependency-preserving.Review: Boyce-Codd Normal Form3NF: R is in 3NF if and only iffor each FD: X A in F+A X (trivial FD), o
5、rX is a superkey for R, orA is prime attribute for R If a relation is in BCNF, it is in 3NF (since BCNF permits only the first two conditions).If every FD that does not contain extraneous (useless) attributes, then for each X A , X must be a candidate key, or A must belong to a candidate key.The dec
6、omposition is both lossless-join and dependency-preserving.Review: Third Normal FormR =(A, B, C, D).F = CD, CA, BC.Question 1: Identify all candidate keys for R.Question 2: Does R satisfy 3NF or BCNF?Question 3: Decompose R into a set of BCNF relations.Question 4: Decompose R into a set of 3NF relat
7、ions.Exercise 3R =(A, B, C, D).F = CD, CA, BC.Question 1: Identify all candidate keys for R. B+ = B (BB) = BC (BC) = BCD (CD) = ABCD (CA) so the candidate key is B. B is the ONLY candidate key, because nothing determines B: There is no rule that can produce B, except B B.Exercise 3 (cont)R =(A, B, C
8、, D).F = CD, CA, BC. Question 2: Does R satisfy 3NF or BCNF? R is not 3NF, because: CD causes a violation,CD is non-trivial (D C).C is not a superkey.D is not part of any candidate key.CA causes a violationSimilar to aboveBC causes no violation Since R is not 3NF, it is not BCNF either.Exercise 3 (c
9、ont)R =(A, B, C, D).F = CD, CA, BC.Question 3: Decompose R into a set of BCNF relations.CD, CA violas BCNF. Take CD: decompose R to R1= A, B, C , R2=C, D.R1 violates BCNF (because of CA)Decompose R1 to R11 = B, C R12 = C, A.Final decomposition: R2 = C, D, R11 = B, C, R12 = C, A.No more violations: F
10、inished!Exercise 3 (cont)Let R be the initial table with FDs FS=RUntil all relation schemes in S are in BCNFfor each R in S for each FD X Y that violates BCNF for RS = (S R) (R-Y) (X,Y)enduntilR =(A, B, C, D).F = CD, CA, BC.Question 4: Decompose R into a set of 3NF relations.Compute canonical cover
11、Fc = CDA, BC. Create a table for each functional dependency in Fc R1 = C, D, A, R2 = B, C.The table R2 contains the candidate key Finished. Exercise 3 (cont)Compute the canonical cover Fc of FS=for each FD XY in the canonical cover FcS=S(X,Y) if no scheme contains a candidate key for R Choose any ca
12、ndidate key CNS=S table with attributes of CNExercise 4R = (A, B, C, D) F = ABC, ABD, CA, DBIs R in 3NF, why? If it is not, decompose it into 3NFIs R in BCNF, why? If it is not, decompose it into BCNFExercise 4R = (A, B, C, D) F = ABC, ABD, CA, DBIs R in 3NF, why? If it is not, decompose it into 3NF
13、Yes. Find all the Candidate Keys: AB, BC, CD, AD Check all FDs in F for 3NF condition2. Is R in BCNF, why? If it is not, decompose it into BCNFNo. CA, C is not a superkey. Similar for DBBegin with CA or begin with DB get the same result: R1 = C, D, R2 = A, C, R3 = B, DMore Exercise 5R = (A, B, C, D)F = ABCD, DA 1. Identify all the candidate keys for RCandidate keys: ABC, BCD 2. Identify the highest normal form that R satisfiesR is in 3NF but not BCNF. 3. If R is not in BCNF, decompose it into a set of BCNF relations that
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026福建同安第一中学附属学校校园招聘考试备考试题及答案解析
- 2026广西玉林福绵区就业服务中心招聘见习生1人考试备考题库及答案解析
- 2026年春季学期广东广州市天河区同仁天兴学校招聘4人考试备考试题及答案解析
- 2026上海虹口区委党校招聘专职教师1人考试参考试题及答案解析
- 2026年宁夏招录选调生选报考试备考题库及答案解析
- 2026中国人民银行清算总中心直属企业深圳金融电子结算中心有限公司招聘14人考试备考试题及答案解析
- 2026福汽集团校园招聘279人考试参考试题及答案解析
- 2026年上海市嘉定区嘉一实验初级中学教师招聘考试参考题库及答案解析
- 2026年上海烟草集团有限责任公司应届生招聘考试备考题库及答案解析
- 家庭养老护理急救注意事项
- 北京师范大学介绍
- 代办职称协议书
- 乳房再造教学课件
- 售后技术服务流程规范
- 生活垃圾收集容器选型与配置方案
- 六性分析报告标准格式与范例
- 2025年西安交通大学少年班招生考试初试数学试题(初中组)+答案
- 急性肺栓塞诊断和治疗指南(2025版)解读课件
- 供水管网施工期间居民供水保障方案
- 2026届新高考化学热点复习水溶液的多重平衡图像
- 江苏省常州市钟楼区小学语文三年级上册期末检测卷(含答案)
评论
0/150
提交评论