DBMS Appendix C

download DBMS Appendix C

of 12

Transcript of DBMS Appendix C

  • 8/9/2019 DBMS Appendix C

    1/12

  • 8/9/2019 DBMS Appendix C

    2/12

    Silberschatz, Korth and SudarshanC.2Database System Concepts, 5th Ed.

    Theory ofTheory of MultivaluedMultivalued DependenciesDependencies

    Let Ddenote a set of functional and multivalued dependencies. Theclosure D+ of Dis the set of all functional and multivalueddependencies logically implied by D.

    Sound and complete inference rules for functional and multivalued

    dependencies:

    1. Reflexivity rule. If is a set of attributes and , then holds.

    2. Augmentation rule. If holds and is a set of attributes, then

    holds.3. Transitivity rule. If holds and holds, then holds.

  • 8/9/2019 DBMS Appendix C

    3/12

    Silberschatz, Korth and SudarshanC.3Database System Concepts, 5th Ed.

    Theory of Multivalued Dependencies (Cont.)Theory of Multivalued Dependencies (Cont.)

    4. Complementation rule. If holds, then Rholds.

    5. Multivalued augmentation rule. If holds and Rand , then holds.

    6. Multivalued transitivity rule. If holds and holds,then holds.

    7. Replication rule. If holds, then .

    8. Coalescence rule. If holds and and there is a such that Rand = and , then holds.

  • 8/9/2019 DBMS Appendix C

    4/12Silberschatz, Korth and SudarshanC.4Database System Concepts, 5th Ed.

    Simplification of the Computation ofSimplification of the Computation of DD++

    We can simplify the computation of the closure of Dby using the followingrules (proved using rules 1-8).

    Multivalued union rule. If holds and holds, then holds.

    Intersection rule. If holds and holds, then holds.

    Difference rule. If If holds and holds, then holds and holds.

  • 8/9/2019 DBMS Appendix C

    5/12Silberschatz, Korth and SudarshanC.5Database System Concepts, 5th Ed.

    ExampleExample

    R= (A, B, C, G, H, I)D ={A B

    B HI

    CG H}

    Some members of D+:

    A CGHI.Since A B, the complementation rule (4) impliesthat A R B A.Since R B A = CGHI, so A CGHI.

    A HI.Since A Band B HI, the multivalued transitivityrule (6) implies that B HI B.Since HI B = HI, A HI.

  • 8/9/2019 DBMS Appendix C

    6/12Silberschatz, Korth and SudarshanC.6Database System Concepts, 5th Ed.

    Example (Cont.)Example (Cont.)

    Some members of D+(cont.):

    B H.Apply the coalescence rule (8); B HIholds.

    Since H HIand CG Hand CG HI= , the

    coalescence rule is satisfied with being B, being HI, beingCG, and being H. We conclude that B H.

    A CG.A CGHIand A HI.

    By the difference rule, A CGHIHI.Since CGHIHI = CG, A CG.

  • 8/9/2019 DBMS Appendix C

    7/12Silberschatz, Korth and SudarshanC.7Database System Concepts, 5th Ed.

    Normalization Using Join DependenciesNormalization Using Join Dependencies

    Join dependencies constrain the set of legal relations over a schema Rtothose relations for which a given decomposition is a lossless-joindecomposition.

    Let Rbe a relation schema and R1 , R2 ,..., Rnbe a decomposition of R. If R =

    R1 R2 . Rn, we say that a relation r(R) satisfies thejoin dependency*(R1 , R2 ,..., Rn) if:

    r=R1 (r) R2(r) Rn(r)

    A join dependency is trivial if one of the Ri is Ritself. A join dependency *(R1, R2) is equivalent to the multivalued dependency R1

    R2 R2. Conversely, is equivalent to *( (R- ), )

    However, there are join dependencies that are not equivalent to any

    multivalued dependency.

  • 8/9/2019 DBMS Appendix C

    8/12Silberschatz, Korth and SudarshanC.8Database System Concepts, 5th Ed.

    ProjectProject--Join Normal Form (PJNF)Join Normal Form (PJNF)

    A relation schema Ris in PJNF with respect to a set Dof functional,multivalued, and join dependencies if for all join dependencies in D+ of theform

    *(R1 , R2 ,..., Rn) where each Ri R

    and R=R1 R2 ... Rn

    at least one of the following holds:

    *(R1 , R2 ,..., Rn) is a trivial join dependency.

    Every Ri is a superkey for R.

    Since every multivalued dependency is also a join dependency,

    every PJNF schema is also in 4NF.

  • 8/9/2019 DBMS Appendix C

    9/12Silberschatz, Korth and SudarshanC.9Database System Concepts, 5th Ed.

    ExampleExample

    Consider Loan-info-schema= (branch-name, customer-name, loan-number, amount).

    Each loan has one or more customers, is in one or more branches and hasa loan amount; these relationships are independent, hence we have the join

    dependency

    *(=(loan-number, branch-name), (loan-number, customer-name), (loan-number, amount))

    Loan-info-schemais not in PJNF with respect to the set of dependenciescontaining the above join dependency. To put Loan-info-schemainto PJNF,we must decompose it into the three schemas specified by the joindependency:

    (loan-number, branch-name) (loan-number, customer-name)

    (loan-number, amount)

  • 8/9/2019 DBMS Appendix C

    10/12Silberschatz, Korth and SudarshanC.10Database System Concepts, 5th Ed.

    DomainDomain--Key Normal Form (DKNY)Key Normal Form (DKNY)

    Domain declaration. Let A be an attribute, and let dom be a set ofvalues. The domain declaration A dom requires that the A value ofall tuples be values in dom.

    Key declaration. Let Rbe a relation schema with K R. The key

    declaration key (K) requires that Kbe a superkey for schema R(KR). All key declarations are functional dependencies but not allfunctional dependencies are key declarations.

    General constraint. A general constraint is a predicate on the set ofall relations on a given schema.

    Let D be a set of domain constraints and let K be a set of keyconstraints for a relation schema R. Let G denote the generalconstraints for R. Schema Ris in DKNF if D K logically imply G.

  • 8/9/2019 DBMS Appendix C

    11/12Silberschatz, Korth and SudarshanC.11Database System Concepts, 5th Ed.

    ExampleExample

    Accounts whose account-numberbegins with the digit 9 are specialhigh-interest accounts with a minimum balance of 2500.

    General constraint: ``If the first digit of t[account-number] is 9, then t[balance] 2500.''

    DKNF design:

    Regular-acct-schema= (branch-name, account-number,balance)

    Special-acct-schema= (branch-name, account-number,balance)

    Domain constraints for {Special-acct-schema} require that for eachaccount:

    The account number begins with 9.

    The balance is greater than 2500.

  • 8/9/2019 DBMS Appendix C

    12/12Silberschatz, Korth and SudarshanC.12Database System Concepts, 5th Ed.

    DKNF rephrasing of PJNF DefinitionDKNF rephrasing of PJNF Definition

    Let R= (A1 , A2 ,..., An) be a relation schema. Let dom(Ai) denote thedomain of attribute Ai, and let all these domains be infinite. Then all

    domain constraints D are of the form Ai dom (Ai).

    Let the general constraints be a set G of functional, multivalued, or

    join dependencies. If Fis the set of functional dependencies in G, letthe set K of key constraints be those nontrivial functional

    dependencies in F+ of the form R.

    Schema Ris in PJNF if and only if it is in DKNF with respect to D, K,

    and G.