Top Banner

of 25

Lossless Join ppt

Jun 03, 2018

Download

Documents

Vinayak Wadhwa
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/12/2019 Lossless Join ppt

    1/25

    Goal of Decomposition

    Eliminate redundancy by decomposing a relation

    into several relations in a higher normal form.

    It is important to check that a decomposition

    does not lead to bad design

    There are three desirable properties:

    1. Lossless.

    2. Dependency preservation.

    3. Minimal redundancy.

  • 8/12/2019 Lossless Join ppt

    2/25

    Problem with Decomposition

    Given instances of the decomposed relations,

    we may not be able to reconstruct the

    corresponding instance of the original

    relationinformation loss

  • 8/12/2019 Lossless Join ppt

    3/25

  • 8/12/2019 Lossless Join ppt

    4/25

    Example : Problem with Decomposition

    R1 U R2Model Name Price Categorya11 100 Canon

    a11 150 Canon

    s20 200 Nikon

    a70 100 Canona70 150 Canon

    Model Name Price Category

    a11 100 Canon

    s20 200 Nikon

    a70 150 Canon

    R

  • 8/12/2019 Lossless Join ppt

    5/25

    Lossy decomposition

    In previous example, additional tuples are

    obtained along with original tuples

    Although there are more tuples, this leads to

    less information

    Due to the loss of information, decomposition

    for previous example is called lossy

    decompositionor lossy-join decomposition

  • 8/12/2019 Lossless Join ppt

    6/25

    Example of Relation Decomposition

  • 8/12/2019 Lossless Join ppt

    7/25

    Lossless Decomposition

    A decomposition {R1, R2,, Rn} of a relation R iscalled a losslessdecompositionfor R if thenatural join of R1, R2,, Rn produces exactly therelation R.

    Definition:

    Let { R1, R2 } be a decomposition of R (R1 U

    R2 = R); the decomposition is lossless if forevery legal instance r of R:

    r = R1(r) |X| R2(r)

  • 8/12/2019 Lossless Join ppt

    8/25

    Lossless Decomposition

    A decomposition is lossless if we can recover:

    R(A, B, C)

    Decompose

    R1(A, B) R2(A, C)

    Recover

    R(A, B, C)

    Thus, R = R

  • 8/12/2019 Lossless Join ppt

    9/25

    Lossless Check Example 1:

    Consider five attributes: ABCDE

    Three relations: ABC, AD, BDE

    FDs: A ->BD, B ->E

    A B C D E

    ABC a1 a2 a3 b14 b15

    AD a1 b22 b23 a4 b25

    BDE b21 a2 b33 a4 a5

  • 8/12/2019 Lossless Join ppt

    10/25

    Lossless Check Example

  • 8/12/2019 Lossless Join ppt

    11/25

    Lossless Check Example

  • 8/12/2019 Lossless Join ppt

    12/25

    Example 2:

    R1 (A1, A2, A3, A5)

    R2 (A1, A3, A4)

    R3 (A4, A5)

    FD1: A1A3 A5

    FD2: A5A1 A4

    FD3: A3 A4A2

  • 8/12/2019 Lossless Join ppt

    13/25

    A1 A2 A3 A4 A5

    R1 a(1) a(2) a(3) b(1,4) a(5)

    R2 a(1) b(2,2) a(3) a(4) b(2,5)

    R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

    Example (cont)

  • 8/12/2019 Lossless Join ppt

    14/25

    By FD1: A1A3 A5

    A1 A2 A3 A4 A5

    R1 a(1) a(2) a(3) b(1,4) a(5)

    R2 a(1) b(2,2) a(3) a(4) b(2,5)

    R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

    Example (cont)

  • 8/12/2019 Lossless Join ppt

    15/25

    By FD1: A1A3 A5

    we have a new result table

    A1 A2 A3 A4 A5

    R1 a(1) a(2) a(3) b(1,4) a(5)

    R2 a(1) b(2,2) a(3) a(4) a(5)

    R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

    Example (cont)

  • 8/12/2019 Lossless Join ppt

    16/25

    By FD2: A5A1 A4

    A1 A2 A3 A4 A5

    R1 a(1) a(2) a(3) b(1,4) a(5)

    R2 a(1) b(2,2) a(3) a(4) a(5)

    R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

    Example (cont)

  • 8/12/2019 Lossless Join ppt

    17/25

    By FD2: A5A1 A4

    we have a new result table

    A1 A2 A3 A4 A5

    R1 a(1) a(2) a(3) a(4) a(5)

    R2 a(1) b(2,2) a(3) a(4) a(5)R3 a(1) b(3,2) b(3,3) a(4) a(5)

    Example (cont)

  • 8/12/2019 Lossless Join ppt

    18/25

    Why do we preserve the dependency?

    We would like to check easily that updates to

    the database do not result in illegal relations

    being created.

    It would be nice if our design allowed us to

    check updates without having to compute

    natural joins.

  • 8/12/2019 Lossless Join ppt

    19/25

    Dependency Preservation Decomposition

    Definition: Each FD specified in F either appears directly in

    one of the relations in the decomposition, or be inferred from

    FDs that appear in some relation.

  • 8/12/2019 Lossless Join ppt

    20/25

    Test of Dependency Preservation

    If a decomposition is not dependency-preserving, some

    dependency is lost in the decomposition.

    One way to verify that a dependency is not lost is to take

    joins of two or more relations in the decomposition to geta relation that contains all of the attributes in the

    dependency under consideration and then check that the

    dependency holds on the result of the joins.

  • 8/12/2019 Lossless Join ppt

    21/25

    Test of Dependency Preservation II

    Find F- F', the functional dependencies not

    checkable in one relation.

    See whether this set is obtainable from F' by

    using Armstrong's Axioms.

    This should take a great deal less work, as we

    have (usually) just a few functional

    dependencies to work on.

  • 8/12/2019 Lossless Join ppt

    22/25

    Dependency Preserving Example

    Consider relation ABCD, with FDs :

    A ->B, B ->C, C ->D

    Decompose into two relations: ABC and CD.

    ABC supports the FDs A->B, B->C.

    CD supports the FD C->D.

    All the original dependencies are preserved.

  • 8/12/2019 Lossless Join ppt

    23/25

    Non-Dependency Preserving Example

    Consider relation ABCD, with FDs:

    A ->B, B ->C, C->D

    Decompose into two relations: ACD and BC.

    ACD supports the FD B ->C and implied FD A ->C.

    BC supports the FD B->C.

    However, no relation supports A ->B.

    So the dependency is not preserved.

  • 8/12/2019 Lossless Join ppt

    24/25

    Minimal Redundancy

    In order to achieve the lack of redundancy, we

    do some decomposition which is represented

    by several normal forms.

  • 8/12/2019 Lossless Join ppt

    25/25

    Conclusion

    Decompositions should always be lossless.

    Decompositions should be dependency

    preserving whenever possible.

    We have to perform the normal decomposition

    to make sure we get rid of the minimal

    redundant information.