Normalization-Database systems-Lecture 04 Slides-Computer Science, Slides of Database Management Systems (DBMS)

This course is about database management systems. Main topics covered in this course are: manipulate data, use standard query language, creating a database and logical query language.Normalization, Boyce-codd Normal Form, Nontrivial FD, Redundancy, Update Anomalies, Deletion Anomalies, Decomposition, 3NF, Multivalued Dependencies, 4NF

Typology: Slides

2011/2012

Uploaded on 01/31/2012

marphy
marphy 🇺🇸

4.4

(31)

284 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Normalization
Goal = BCNF = Boyce-Codd Normal Form = all
FD's follow from the fact \key
!
everything."
Formally,
R
is in BCNF if every nontrivial FD
for
R
,say
X
!
A
, has
X
a superkey.
\Nontrivial" = right-side attribute not in
left side.
Why?
1. Guarantees no redundancy due to FD's.
2. Guarantees no
update anomalies
= one
occurrence of a fact is up dated, not all.
3. Guarantees no
deletion anomalies
=valid fact
is lost when tuple is deleted.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Normalization-Database systems-Lecture 04 Slides-Computer Science and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Normalization

Goal = BCNF = Boyce-Co dd Normal Form = all FD's follow from the fact \key! everything."

 Formally, R is in BCNF if every nontrivial FD for R , say X! A, has X a sup erkey. F \Nontrivial" = right-side attribute not in left side.

Why?

  1. Guarantees no redundancy due to FD's.
  2. Guarantees no update anomalies = one o ccurrence of a fact is up dated, not all.
  3. Guarantees no deletion anomalies = valid fact is lost when tuple is deleted.

Example of Problems

Drinkers(name , addr, beersLiked , manf, favoriteBeer)

name addr b eersLiked manf favoriteBeer Janeway Voyager Bud A.B. WickedAle Janeway ??? WickedAle Pete's ??? Sp o ck Enterprise Bud ??? Bud

FD's:

  1. name! addr
  2. name! favoriteBeer
  3. beersLiked! manf

 ???'s are redundant, since we can gure them out from the FD's.

 Up date anomalies: If Janeway gets transferred to the Intrepid, will we rememb er to change addr in each of her tuples?

 Deletion anomalies: If nob o dy likes Bud, we lose track of Bud's manufacturer.

Decomp osition to Reach BCNF

Setting: relation R , given FD's F. Supp ose relation R has BCNF violati on X! B.

 We need only lo ok among FD's of F for a BCNF violati on, not those that follow from F. Why?

  1. Compute X +^.

F Cannot b e all attributes | why?

  1. Decomp ose R into X +^ and (R X +^ ) [ X.

R X X +

  1. Find the FD's for the decomp osed relations.

F Pro ject the FD's from F = calculate all consequents of F that involve only attributes from X +^ or only from (R X +^ ) [ X.

Example

R = Drinkers(name , addr, beersLiked , manf, favoriteBeer)

F =

  1. name! addr
  2. name! favoriteBeer
  3. beersLiked! manf

Pick BCNF violati on name! addr.

 Close the left side: name +^ = name addr favoriteBeer.

 Decomp osed relations:

Drinkers1(name , addr, favoriteBeer) Drinkers2(name , beersLiked , manf)

 Pro jected FD's (skipping a lot of work that leads nowhere interesting): F For Drinkers1: name! addr and name! favoriteBeer. F For Drinkers2: beersLiked! manf.

3NF

One FD structure causes problems:

 If you decomp ose, you can't check the FD's in the decomp osed relations.

 If you don't decomp ose, you violate BCNF.

Abstractly: AB! C and C! B.

 In b o ok: title city! theatre and theatre ! city.

 Another example: street city! zip, zip! city.

Keys: fA; B g and fA; C g, but C! B has a left side not a sup erkey.

 Suggests decomp osition into B C and AC.

F But you can't check the FD AB! C in these relations.

Example

A = street, B = city, C = zip.

street zip 545 Tech Sq. 02138 545 Tech Sq. 02139

city zip Cambridge 02138 Cambridge 02139

Join:

city street zip Cambridge 545 Tech Sq. 02138 Cambridge 545 Tech Sq. 02139

What 3NF Gives You

There are two imp ortant prop erties of a decomp osition:

  1. We should b e able to recover from the decomp osed relations the data of the original. F Recovery involves pro jection and join, which we shall defer until we've discussed relational algebra.
  2. We should b e able to check that the FD's for the original relation are satis ed by checking the pro jections of those FD's in the decomp osed relations.

 Without pro of, we assert that it is always p ossible to decomp ose into BCNF and satisfy (1).

 Also without pro of, we can decomp ose into 3NF and satisfy b oth (1) and (2).

 But it is not p ossible to decomp ose into BNCF and get b oth (1) and (2). F Street-city-zi p is an example of this p oint.

Multivalued Dep endencies

The multivalued dependency X !! Y holds in a relation R if whenever we have two tuples of R that agree in all the attributes of X , then we can swap their Y comp onents and get two new tuples that are also in R.

X Y others

MVD Rules

  1. Every FD is an MVD.

F Because if X! Y , then swapping Y 's b etween tuples that agree on X do esn't create new tuples. F Example, in Drinkers: name !! addr.

  1. Complementation: if X !! Y , then X !! Z , where Z is all attributes not in X or Y. F Example: since name !! phones holds in Drinkers, so do es name !! addr beersLiked.

Splitting Do esn't Hold

Sometimes you need to have several attributes on the right of an MVD. For example:

Drinkers(name, areaCode, phones, beersLiked, beerManf)

name areaCo de phones BeersLiked b eerManf Sue 650 555-1111 Bud A.B. Sue 650 555-1111 WickedAle Pete's Sue 415 555-9999 Bud A.B. Sue 415 555-9999 WickedAle Pete's

 name !! areaCode phones holds, but neither name !! areaCode nor name !! phones do.

Example

Drinkers(name, addr, phones, beersLiked)

 FD: name! addr

 Nontrivial MVD's: name !! phones and name !! beersLiked.

 Only key: fname, phones, beersLikedg

 All three dep endencies ab ove violate 4NF.

 Successive decomp osition yields 4NF relations:

D1(name , addr) D2(name , phones ) D3(name , beersLiked )