数据库课件总结:Database Chapter Seven Outline_第1页
数据库课件总结:Database Chapter Seven Outline_第2页
数据库课件总结:Database Chapter Seven Outline_第3页
数据库课件总结:Database Chapter Seven Outline_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Database Chapter Seven OutlineTrivial:A functional dependency is trivial if it is satisfied by all instances of a relationClosure:The set of all functional dependencies logically implied by F is the closure of F.We denote the closure of F by F+.F+ is a superset of F. BCNF:A relation schema R is in B

2、CNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a b where a R and b R, at least one of the following holds:a b is trivial (i.e., b a)a is a superkey for RDecomposing a Schema into BCNFSuppose we have a schema R and a non-trivial dependency

3、a b causes a violation of BCNF.We decompose R into:(a U b ) ( R - ( b - a ) ) 可能会进行BCNF分解时会产生更多不属于BCNF的结果模式,在这种情况下要进行进一步的分解,直至最后产生的结果是一个BCNF模式的集合。dependency preserving:If it is sufficient to test only those dependencies on each individual relation of a decomposition in order to ensure that all funct

4、ional dependencies hold, then that decomposition is dependency preserving.Decide a decomposition is good or bad Lossless-join decide whether the relation is able to decompose or notBecause it is not always possible to achieve both BCNF and dependency preservation, we consider a weaker normal form, k

5、nown as third normal form.模式分解的目标:保持依赖的,无损分解,坚持BCNF模式的分解可能会导致非保持依赖的。Third Normal FormA relation schema R is in third normal form (3NF) if for all:a b in F+at least one of the following holds:a b is trivial (i.e., b a)a is a superkey for R Each attribute A in b a is contained in a candidate key for R

6、. (NOTE: each attribute may be in a different candidate key) Third condition is a minimal relaxation of BCNF to ensure dependency preservationClosure of a Set of Functional DependenciesGiven a relational schema R, a functional dependency f on R is logically implied by a set functional dependencies F

7、 on R if every relation instance r(R) that satisfies F also satisfies f.if b a, then a b (reflexivity) if a b, then g a g b (augmentation) if a b, and b g, then a g (transitivity)If a b holds and a g holds, then a b g holds (union) If a b g holds, then a b holds and a g holds (decomposition) If a b

8、holds and g b d holds, then a g d holds (pseudotransitivity) To compute the closure of a set of functional dependencies F: F + = Frepeatfor each functional dependency f in F+ apply reflexivity and augmentation rules on f add the resulting functional dependencies to F +for each pair of functional dep

9、endencies f1and f2 in F + if f1 and f2 can be combined using transitivity then add the resulting functional dependency to F +until F + does not change any furtherClosure of Attribute SetsGiven a set of attributes a, define the closure of a under F (denoted by a+) as the set of attributes that are fu

10、nctionally determined by a under F Algorithm to compute a+, the closure of a under F result := a;while (changes to result) dofor each b g in F dobeginif b result then result := result g end Uses of Attribute Closureesting for superkey:Testing functional dependenciesComputing closure of FComputation

11、of candidate keyIf attribute A doesnt appear in any side of f, then A should be part of candidate key If attribute A appear only in the left side of f, then A should be part of candidate key If attribute A appear only in the right side of f, then A would not be part of candidate key If attribute A a

12、ppear in both sides of f, then A should be tested further, and Attribute Closure could be used.当属性A不出现在函数依赖两边,或者只出现在左边时候,A应该是候选码的一部分。出现在两边时,应该进一步计算其闭包。Canonical Cover 正则闭包Intuitively, a canonical cover of F is a “minimal” set of functional dependencies equivalent to F, having no redundant dependenci

13、es or redundant parts of dependencies To test if attribute A a is extraneous in a compute (a A)+ using the dependencies in F 用原来函数依赖关系 check that (a A)+ contains b; if it does, A is extraneous To test if attribute A b is extraneous in b 用去除属性后的函数依赖关系compute a+ using only the dependencies in F = (F a

14、 b) a (b A), check that a+ contains A; if it does, A is extraneousA canonical cover for F is a set of dependencies Fc such that F logically implies all dependencies in Fc, and Fc logically implies all dependencies in F, andNo functional dependency in Fc contains an extraneous attributeEach left side

15、 of functional dependency in Fc is uniqueTo compute a canonical cover for F:repeatUse the union rule to replace any dependencies in F a1 b1 and a1 b2 with a1 b1 b2 Find a functional dependency a b with an extraneous attribute either in a or in b If an extraneous attribute is found, delete it from a

16、b until F does not changeLossless-join DecompositionA decomposition of R into R1 and R2 is lossless join if and only if at least one of the following dependencies is in F+:R1 R2 R1R1 R2 R2 如果R1 R2 是 R1 或者R2 的超码,则是无损分解。Dependency PreservationA decomposition is dependency preserving, if (F1 F2 Fn )+ =

17、 F +方法一:计算F+ 与F+ 比较是否相等。方法二:To check if a dependency a b is preserved in a decomposition of R into R1, R2, , Rn we apply the following test (with attribute closure done with respect to F)result = awhile (changes to result) dofor each Ri in the decompositiont = (result Ri)+ Riresult = result tIf resu

18、lt contains all attributes in b, then the functional dependency a b is preserved.Testing Decomposition for BCNFfor every set of attributes a Ri, check that a+ (the attribute closure of a under F) either includes no attribute of Ri- a, or includes all attributes of Ri.If the condition is violated by

19、some a b in F+, the dependency a (a+ - a ) Rican be shown to hold on Ri, and Ri violates BCNF.BCNF Decomposition Algorithmresult := R ;done := false;compute F +;while (not done) doif (there is a schema Ri in result that is not in BCNF)then beginlet a b be a nontrivial functional dependency that holds on Ri such that a Ri is not in F +, and a b = ;result := (result Ri ) (Ri b) (a, b ); endelse done := true;3NF Decomposition AlgorithmAbove algorithm ensures:each relation schema

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论