PowerPoint PresentationSlide 2Normal FormsLossless Schema DecompositionLossy DecompositionLossy Decompositions: What is Actually Lost?Testing for LosslessnessExampleIntuition Behind the Test for LosslessnessProof of Lossless ConditionDependency PreservationSlide 12Slide 13Slide 14Slide 15BCNF Decomposition AlgorithmSimple ExampleA Larger ExampleExample (con’t)Properties of BCNF Decomposition AlgorithmSlide 21Third Normal FormMinimal CoverComputing Minimal CoverComputing Minimal Cover (con’t)Synthesizing a 3NF SchemaSynthesizing a 3NF schema (con’t)Slide 28Slide 29Overall Design StrategySlide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39Slide 40Slide 41Slide 42BCNF(non) BCNF ExamplesRedundancySlide 463NF Example3NF (Non) ExampleDecompositionsDecompositionExample DecompositionSlide 52Slide 53Slide 54Slide 55Slide 56Slide 57Slide 58Slide 59Slide 60Slide 61Slide 62Slide 63Slide 64Slide 65Slide 66Slide 67Functional Dependencies and KeysFunctional DependenciesHow to Compute Meaning - Armstrong’s inference rulesHow to Compute Meaning -the meaning of a set of FDs, F+How to Compute Meaning when do sets of FDs mean the same?How to Compute Meaning - minimal cover of a set of FDsHow to guarantee lossless joinsHow to guarantee preservation of FDsNormal Forms - definitionsExample of NormalizationSlide 783NF that is not BCNFMajor Results in Normalization TheoryAnomalies in this TableSlide 82Slide 83Fig– Functional Dependencies in EMPLOYEE2Getting it into 2nd Normal FormSlide 86Slide 87Slide 88Slide 89Slide 90relations {Ri} with some undesirable properties relations {Sk} with better update propertiesRelational Optimisation• Minimized data redundancy• No transaction may• cause loss of information delete anomaly• violate entity integrity insert anomaly• carry any risk of inconsistent updating update anomalyNormal Forms•Each normal form is a set of conditions on a schema that guarantees certain properties (relating to redundancy and update anomalies)•First normal form (1NF) is the same as the definition of relational model (relations = sets of tuples; each tuple = sequence of atomic values)•Second normal form (2NF) – a research lab accident; has no practical or theoretical value – won’t discuss•The two commonly used normal forms are third third normal formnormal form (3NF) and Boyce-Codd normal formBoyce-Codd normal form (BCNF)Lossless Schema Decomposition•A decomposition should not lose information•A decomposition (R1,…,Rn) of a schema, R, is losslesslossless if every valid instance, r, of R can be reconstructed from its components:•where each ri = Ri(r)r = r1r2rn……Lossy Decompositionr r1 r2...rnSSN Name Address SSN Name Name Address1111 Joe 1 Pine 1111 Joe Joe 1 Pine2222 Alice 2 Oak 2222 Alice Alice 2 Oak3333 Alice 3 Pine 3333 Alice Alice 3 Piner r1 r2rn...r1r2rThe following is always the case (Think why?):But the following is not always true:Example:The tuples (2222, Alice, 3 Pine) and (3333, Alice, 2 Oak) are in the join, but not in the originalLossy Decompositions: What is Actually Lost?•In the previous example, the tuples (2222, Alice, 3 Pine) and (3333, Alice, 2 Oak) were gained, not lost! –Why do we say that the decomposition was lossy?•What was lost is information:–That 2222 lives at 2 Oak: In the decomposition, 2222 can live at either 2 Oak or 3 Pine–That 3333 lives at 3 Pine: In the decomposition, 3333 can live at either 2 Oak or 3 PineTesting for Losslessness•A (binary) decomposition of R = (R, F) into R1 = (R1, F1) and R2 = (R2, F2) is lossless if and only if :–either the FD•(R1 R2 ) R1 is in F+ –or the FD•(R1 R2 ) R2 is in F+ExampleSchema (R, F) where R = {SSN, Name, Address, Hobby} F = {SSN Name, Address}can be decomposed into R1 = {SSN, Name, Address} F1 = {SSN Name, Address}and R2 = {SSN, Hobby} F2 = { }Since R1 R2 = SSN and SSN R1 thedecomposition is losslessIntuition Behind the Test for Losslessness•Suppose R1 R2 R2 . Then a row of r1 can combine with exactly one row of r2 in the natural join (since in r2 a particular set of values for the attributes in R1 R2 defines a unique row) R1 R2 R1 R2 …………. a a ………...………… a b ………….………… b c ………….………… c r1 r2If R1 R2 R2 then card (r1 Proof of Lossless Condition• r r1 r2 – this is true for any decompositionr2) = card (r1) But card (r) card (r1) (since r1 is a projection of r)and therefore card (r) card (r1 r2) Hence r = r1r2• r r1 r2(since each row of r1 joins with exactly one row of r2)Dependency Preservation•Consider a decomposition of R = (R, F) into R1 = (R1, F1) and R2 = (R2, F2)–An FD X Y of F+ is in Fi iff X Y Ri–An FD, f F+ may be in neither F1, nor F2, nor even (F1 F2)+ •Checking that f is true in r1 or r2 is (relatively) easy•Checking f in r1 r2 is harder – requires a join•Ideally: want to check FDs locally, in r1 and r2, and have a guarantee that every f F holds in r1 r2 •The decomposition is dependency preservingdependency preserving iff the sets F and F1 F2 are equivalent: F+ = (F1 F2)+–Then checking all FDs in F, as r1 and r2 are updated, can be done by checking F1 in r1 and F2 in r2Dependency Preservation•If f is an FD in F, but f is not in F1 F2, there are two possibilities:–f (F1 F2)+ •If the constraints in F1 and F2 are maintained, f will be maintained automatically.–f (F1 F2)+ •f can be checked only by first taking the join of r1 and r2. This is costly.ExampleSchema (R, F) where R = {SSN, Name, Address, Hobby} F = {SSN Name, Address}can be decomposed into R1 = {SSN, Name, Address} F1 = {SSN Name, Address}and R2 = {SSN, Hobby} F2 = { }Since F = F1 F2 the decomposition isdependency preservingExample•Schema: (ABC; F) , F = {A B, B C, C B}•Decomposition:–(AC, F1), F1 = {AC}•Note: AC F, but in F+–(BC, F2), F2 = {B C, C B}•A B (F1 F2), but A B (F1 F2)+.–So F+ = (F1 F2)+ and thus the decompositions is still dependency preservingExample•HasAccountHasAccount (AcctNum, ClientId,
View Full Document