Docsity

Functional and Multivalued Dependencies and Database Normalization, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Functional and Multivalued Dependencies and Database Normalization and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Lossless Decomposition& 4NF

1. Closure

  • Given a set of functional dependencies, F, its closure, F +^ , is all FDs that are implied by FDs in F.
  • e.g. If A ๏ƒ  B, and B ๏ƒ  C,
  • then clearly A ๏ƒ  C

Additional rules

  • If ฮฑ โ†’ ฮฒ a nd ฮฑ โ†’ ฮณ, then ฮฑ โ†’ ฮฒ ฮณ (union)
  • If ฮฑ โ†’ ฮฒ ฮณ, then ฮฑ โ†’ ฮฒ and ฮฑ โ†’ ฮณ (decomposition)
  • If ฮฑ โ†’ ฮฒ and ฮณ ฮฒ โ†’ ฮด, then ฮฑ ฮณ โ†’ ฮด

(pseudotransitivity)

The above rules can be inferred from Armstrongโ€™s

axioms.

Example

  • R = (A, B, C, G, H, I) F = { A โ†’ B A โ†’ C CG โ†’ H CG โ†’ I B โ†’ H }
  • Some members of F +
    • A โ†’ H
      • by transitivity from A โ†’ B and B โ†’ H
    • AG โ†’ I
      • by augmenting A โ†’ C with G, to get AG โ†’ CG and then transitivity with CG โ†’ I
    • CG โ†’ HI
      • by augmenting CG โ†’ I to infer CG โ†’ CG I, and augmenting of CG โ†’ H to infer CGI โ†’ HI, and then transitivity

Computing the closure for A

  • Simple algorithm
    1. Start with B = A.
    1. Go over all functional dependencies, ฮฒ โ†’ ฮณ , in F +
    1. If ฮฒ โІ B, then
  • Add ฮณ to B
    1. Repeat till B changes

Example

  • R = (A, B, C, G, H, I) F = { A โ†’ B A โ†’ C CG โ†’ H CG โ†’ I B โ†’ H }
  • (AG) +^?
  • 1. result = AG
    1. result = ABCG (A โ†’ C and A โ†’ B)
    2. result = ABCGH (CG โ†’ H and CG โІ AGBC)
    3. result = ABCGHI (CG โ†’ I and CG โІ AGBCH

Is (AG) a candidate key?

  1. It is a super key.
  2. (A+) = BC, (G+) = G. Docsity.com

Database Normalization

Functional dependency (FD) means that if there is only one possible value of Y for every value of X, then Y is Functionally dependent on X.

Is the following FDs hold?

X โˆ’โˆ’โˆ’โˆ’โˆ’> Y

X Y Z 10 B1 C 10 B2 C 11 B4 C 12 B3 C 13 B1 C 14 B3 C

X โˆ’โˆ’โˆ’โˆ’โˆ’> Y

Z โˆ’โˆ’โˆ’โˆ’โˆ’> Y

Y โˆ’โˆ’โˆ’โˆ’โˆ’> Z Y โˆ’โˆ’โˆ’โˆ’โˆ’> X

  • Functional Dependency is โ€œgoodโ€. With functional dependency the primary key (Attribute A) determines the value of all the other non-key attributes (Attributes B,C,D,etc.)
  • Transitive dependency is โ€œbadโ€. Transitive dependency exists if the primary/candidate key (Attribute A) determines non-key Attribute B, and Attribute B determines non-key Attribute C.
  • If a relation schema has more than one key, each is called a candidate key
  • An attribute in a relation schema R is called prim if it is a member of some candidate key of R

Database Normalization

Transitive Dependence

Give a relation R , Assume the following FD hold:

Note : Both Ename and Address attributes are non-key attributes in R , and since Address depends on a non-Prime attribute Name, which depends on the primary key(EmpNo), a transitive dependency exists

EmpNo EName Salary Address

EmpNo โˆ’ โˆ’โˆ’โˆ’> Ename , Ename โˆ’โˆ’โˆ’โˆ’> Addresst , EmpNo โˆ’โˆ’โˆ’โˆ’> Address

Ename โˆ’โˆ’โˆ’โˆ’ > Address

EmpNo EName Salary Ename^ Address

R1 R

Note : If address is a prime attribute Then R is in 3NF

Modification Anomalies

  • What happens when you want to
    • add a new book?
    • change the address of a patron?
    • delete a patron record?

Patron Name

Patron Address

Book ID

Book Title

Book Author

Borrow Date

Due Date

Return Date

Smith Jones Hart Hicks Rice Jones

12 Elk 25 Sun 73 Sera 22 Main 69 Witt 25 Sun

AAA BBB CCC AAA DDD CCC

Peace War System Peace Spring System

Bart Hine Vang Bart Lyon Vang

2/ 2/ 2/ 2/ 2/ 1/

2/ 2/ 2/ 2/ 2/ 2/

2/ 2/ 2/ 2/ 2/ 2/

Referential Integrity Constraint

  • When we split a relation, we must pay attention to the references across the newly formed relations
  • E.g., a book must exist before it can be checked out: - CHECKOUT [BookID] ร BOOK [BookID]
  • The DBMS or the applications will have to check/enforce constraints

Boyce-Codd Normal Form

  • Every determinant is a candidate key
    • ADVISER(SID,Major,Fname)
    • STU-ADV(SID,Fname) ADV-SUBJ(Fname,Subject)

A Table That Is In 3NF But Not In BCNF

Figure 5.

The Decomposition of a Table Structure to Meet BCNF Requirements

Figure 5.8 Docsity.com