170 likes | 469 Views
Computing Canonical Cover. Souhad M. Daraghma. Canonical Cover. A canonical cover for F is a set of dependencies F c such that F logically implies all dependencies in F c, and F c logically implies all dependencies in F, and
E N D
Computing Canonical Cover Souhad M. Daraghma
Canonical Cover • A canonical coverfor F is a set of dependencies Fc such that • F logically implies all dependencies in Fc, and • Fc logically implies all dependencies in F, and • No functional dependency in Fccontains an extraneous attribute, and • Each left side of functional dependency in Fcis unique • Intuitively, a canonical cover of F is a “minimal” set of functional dependencies equivalent to F, having no redundant dependencies or redundant parts of dependencies
Extraneous Attributes • Consider F, and a functional dependency, A B. • “Extraneous”: Are there any attributes in A or B that can be safely removed ? • Without changing the constraints implied by F
Testing if an Attribute is Extraneous • Consider a set F of functional dependencies and the functional dependency in F. • To test if attribute A is extraneousin • compute ({} – A)+ using the dependencies in F • check that ({} – A)+ contains A; if it does, A is extraneous • To test if attribute A is extraneous in • compute + using only the dependencies in F’ = (F – {}) {(– A)}, • check that + contains A; if it does, A is extraneous
Computing Canonical Cover R = {A,B,C,D,E,F,G,H} F = {ACG, DEG, BCD, CGBD, ACDB, CEAG} Find the canonical cover of F. 1. Union 2. Find a redundant (extraneous) attribute Consider ACDB, Dis extraneous, because ACG and CGBD imply AC CGB So change ACDB into ACB {ACG, DEG, BCD, CGBD, ACB, CEAG}
Computing Canonical Cover {ACG, DEG, BCD, CGBD, ACB, CEAG} 1. Union {ACBG, DEG, BCD, CGBD, CEAG} 2. Find a redundant (extraneous) attribute Consider ACBG, G is extraneous, because ACB, BCD, and DEG imply AC D G So change ACBG into ACB {ACB, DEG, BCD, CGBD, CEAG}
Computing Canonical Cover {ACB, DEG, BCD, CGBD, CEAG} 1. Union 2. Find a redundant (extraneous) attribute Consider CGBD, B is extraneous, because CGD, D EG, CEAG, and AC B imply CG CD CE AC B So change CG BD into CG D {ACB, DEG, BCD, CGD, CEAG}
Compute Canonical Cover {ACB, DEG, BCD, CGD, CEAG} 1. Union 2. Find a redundant (extraneous) attribute Consider CE AG, G is extraneous, because CE A, AC B, BCD, and D EG imply CE AC BC D G So change CE AG into CE A {ACB, DEG, BCD, CGD, CEA}
Compute Canonical Cover {ACB, DEG, BCD, CGD, CEA} No more extraneous attributes FC ={ACB, DEG, BCD, CGD, CEA} * Different order of considering the extraneous attributes can result in different FC
Example2: Computing a Canonical Cover • R = (A, B, C)F = {A BC B C A BABC} • Combine A BC and A B into A BC • Set is now {A BC, B C, AB C} • A is extraneous in ABC • Check if the result of deleting A from AB C is implied by the other dependencies • Yes: in fact, BC is already present! • Set is now {A BC, B C} • C is extraneous in ABC • Check if A C is logically implied by A B and the other dependencies • Yes: using transitivity on A B and B C. • Can use attribute closure of A in more complex cases • The canonical cover is: A B B C
Example3: Computing a Canonical Cover • Given F = {AC, ABC } • B is extraneous in AB C because {AC, AB C} is equivalent to {AC, AC } = {AC} • Given F = {AC, ABCD} • C is extraneous in ABCD because {AC, ABCD} is equivalent to {AC, ABD}