Chase Test Examples

Embed Size (px)

Citation preview

  • 7/22/2019 Chase Test Examples

    1/3

    Chase Test examples

    Remember to also do the other practice problem set! Minimal BasisThe examples from class (which was rushed in the day section):

    1. Suppose we have a relation R(A,B,C,D) and FDs C->D, B->A. Is the following decomposition a lossless join decomposition?:

    S1(A,B), S2(B,C), and S3(C,D)

    2. Suppose R only has one of the two FD: C->D. Would the decomposition above be a lossless join decomposition in that case?

    A new example to play with:

    3. Suppose we have a relation R(A,B,C,D,E,F). Invent a set of FDs that would make the following decomposition a lossless join decomposition:

    S1(A,C,F), S2(B,C,D), S3(D,E), S4(E,F)

    IMPORTANT: Of course we never really invent FDs. They are facts about our domain! But this exercise will help you understand the Chase Test.

    And one more

    4. Suppose we have a relation R(J,K,L,M) with FDs:

    J -> KL

    K -> M

    For each decomposition below, determine whether it would be a lossless join decomposition, given the FDs.

    (a) S1(K, L), S2(L, M)

    (b) S1(J, K, L), S2(L, M)

    (c) S1(J, K, L), S2(K, M)

    (d) S1(J, K), S2(K, L), S3(L, M)(e) S1(J, K), S2(J, L), S3(K, M)

  • 7/22/2019 Chase Test Examples

    2/3

    Another Class Example:

    Attributes: NFLCG

    N FL

    NC G

    (a) Is this lossless: NF, FLC, LCGAssume Table T :=

    N F L C G

    n f 1 2 3

    4 f l c 5

    6 7 l c g

    This is NOT! Try the following relational algebra to check.

    (Select N,F from T ) bowtie ( select F, L C from T) bowtie ( select L, C, G from T )

    (b) Is this: NFC, NLGAssume Table T :=

    N F L C G

    n f 1 c 2

    n 3 l 4 g

    This is LOSSY. Try the following relational algebra to check.

    (Select N,F,C from T ) bowtie ( select N, L, G from T)

  • 7/22/2019 Chase Test Examples

    3/3

    Another Class Example

    Find all the keys:

    A B C D E F G

    A BE

    C B F G

    G A C

    You cant just use brute force (there would be 100+ combinations)

    Hint: Look at the RHS. D does not appear, this means that D must appear in every key!

    Hint: Look at the LFS. B D E F does not appear. But B E F also appear in RHS. This means they are not in any key!

    It seems intuitive that A, C, G could be part of a key since they determine other attributes.

    A C G

    XA D

    +

    X C D+

    X G D+

    x X A C D+

    x X A G D+

    X X C G D+

    So you can see that AD, CD and GD are the only sets that you have to perform something for. The rest are supersets so dont worry about them.