This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

Prof. Sin-Min Lee Department of Computer Science

**Schedule Today: Jan. 15 (T)
**

± Normal Forms, Multivalued Dependencies. ± Read Sections 3.6-3.7. Assignment 1 due.

Jan. 17 (TH)

± Relational Algebra. ± Read Chapter 5. Project Part 1 due.

Jan. 22 (T)

± SQL Queries. ± Read Sections 6.1-6.2. Assignment 2 due.

Jan. 24 (TH)

± Subqueries, Grouping and Aggregation. ± Read Sections 6.3-6.4. Project Part 2 due.

Goal = BCNF = Boyce-Codd Normal Form = Normalization all FD¶s follow from the fact ³key p everything. say X p A. Guarantees no deletion anomalies = valid fact is lost when tuple is deleted. . not all. 3. R is in BCNF if for every nontrivial FD for R. 2.´ Formally. Why? 1. then X is a superkey. Guarantees no update anomalies = one occurrence of a fact is updated. Guarantees no redundancy due to FD¶s. ± ³Nontrivial´ = right-side attribute not in left side.

Pete's ??? WickedAle ??? Bud Example of Problems addr beersLiked manf favoriteBeer FD¶s: 1. beersLiked.Drinkers(name. beersLiked p manf ???¶s are redundant. favoriteBeer) name Janeway Janeway Spock Voyager ??? Enterprise Bud WickedAle Bud A. since we can figure them out from the FD¶s.B. manf. . we lose track of Bud¶s manufacturer. name p favoriteBeer 3. Update anomalies: If Janeway gets transferred to the Intrepid. name p addr 2. addr. will we change addr in each of her tuples? Deletion anomalies: If nobody likes Bud.

FD¶s = name p manf. Another Example Beers(name. manf.Each of the given FD¶s is a BCNF violation: Key = {name. beersLiked} ± Each of the given FD¶s has a left side that is a proper subset of the key. Only key is name. manfAddr). . ± Manf p manfAddr violates BCNF with a left side unrelated to any key. manf p manfAddr.

X cannot be a superkey either. Proof: If Y p A is a BCNF violation and follows from F. given FD¶s F. if Y is not a superkey. We need only look among FD¶s of F for a BCNF violation. and X p B is also a BCNF violation. ± Thus. . Suppose relation R has BCNF violation X p B. ± X must be a subset of Y.Decomposition to Reach BCNF Setting: relation R. not those that follow from F. then the computation of Y+ used at least one FD X p B from F.

Decompose R into X+ and (R±X+) X. ± Project the FD¶s from F = calculate all consequents of F that involve only attributes from X+ or only from (RX+) X. R X X+ 3. Compute X+.1. Find the FD¶s for the decomposed relations. ± Cannot be all attributes ± why? 2. .

name p favoriteBeer 3. favoriteBeer) F= 1. ± For Drinkers2: beersLiked p manf. beersLiked. manf) Example Projected FD¶s (skipping a lot of work that leads nowhere interesting): ± For Drinkers1: name p addr and name p favoriteBeer.R = Drinkers(name. favoriteBeer) Drinkers2(name. name p addr 2. beersLiked p manf Pick BCNF violation name p addr. addr. . manf. addr. Decomposed relations: Drinkers1(name. Close the left side: name + = name addr favoriteBeer. beersLiked.

. ± For Drinkers2. ± For Drinkers2: beersLiked p manf. name is key and all left sides of FD¶s are superkeys. addr. beersLiked. {name. and beersLiked p manf violates BCNF.(Repeating) Decomposed relations: Drinkers1(name. beersLiked} is the key. BCNF violations? ± For Drinkers1. manf) Projected FD¶s: ± For Drinkers1: name p addr and name p favoriteBeer. favoriteBeer) Drinkers2(name.

beersLiked. addr. Decompose Drinkers2 into: Drinkers3(beersLiked. manf) Drinkers4(name. manf. addr. manf) Drinkers4(name. favoriteBeer) Drinkers2(name. manf) Close beersLiked+ = beersLiked. beersLiked) . favoriteBeer) Drinkers3(beersLiked.Decompose Drinkers2 First set of decomposed relations: Drinkers1(name. beersLiked) Resulting relations are all in BCNF: Drinkers1(name.

Example 2: street city p zip. Abstractly: AB p C and C p B. Example 1: title city p theatre and theatre p city. zip p city. Suggests decomposition into BC and AC. If you don¶t decompose. Keys: {A.One FD structure causes 3NF problems: If you decompose. . you can¶t check all the FD¶s only in the decomposed relations. C}. B} and {A. but C p B has a left side that is not a superkey. you violate BCNF. ± But you can¶t check the FD AB p C in only these relations.

545 Tech Sq. BTechcity. 545 02138 545 Tech Sq. zip 02138 02139 .Example A = street. = Sq. city Cambridge Cambridge 02139 zip 02138 02139 street zip zip p city street city p zip Join: city Cambridge Cambridge street 545 Tech Sq. C = zip.

Thus. or 2. A relation R is in 3NF iff (if and only if) for every nontrivial FD X p A. either: 1. . A is prime = member of at least one key. X is a superkey. the canonical problem goes away: you don¶t have to decompose because all attributes are prime.³Elegant´ Workaround Define the problem away.

We should be able to recover from the decomposed relations the data of the original. We should be able to check that the FD¶s for the original relation are satisfied by checking the projections of those FD¶s in the decomposed relations. Without proof. What 3NF Gives You 2. ± Street-city-zip is an example of this point.There are two important properties of a decomposition: 1. we can decompose into 3NF and satisfy both (1) and (2). which we shall defer until we¶ve discussed relational algebra. . ± Recovery involves projection and join. But it is not possible to decompose into BNCF and get both (1) and (2). we assert that it is always possible to decompose into BCNF and satisfy (1). Also without proof.

then we can swap their Y components and get two new tuples that are also in R.Multivalued Dependencies The multivalued dependency X pp Y holds in a relation R if whenever we have two tuples of R that agree in all the attributes of X. X Y others .

. If Drinkers has the two tuples: name addr sue a sue a phones p1 p2 beersLiked b1 b2 it must also have the same tuples with phones components swapped: name addr sue a sue a phones p2 p1 beersLiked b1 b2 Note: we must check this condition for all pairs of tuples that agree on name. addr. phones.Example Drinkers(name. beersLiked) with MVD Name pp phones. not just one pair.

Complementation: if X pp Y. . where Z is all attributes not in X or Y. then swapping Y¶s between tuples that agree on X doesn¶t create new tuples. 2. ± Example. so does name pp addr beersLiked.1. MVD Rules ± Because if X pY. ± Example: since name pp phones holds in Drinkers. then X pp Z.Every FD is an MVD. in Drinkers: name pp addr.

Splittingseveral attributesHold of an Doesn¶t on the right Sometimes you need to have MVD. areaCode. .B. but neither name pp areaCode nor name pp phones do. Pete¶s A.B. For example: Drinkers(name. beerManf) name Sue Sue Sue Sue areaCode 831 831 408 408 phones 555-1111 555-1111 555-9999 555-9999 beersLiked Bud Wicked Ale Bud Wicked Ale beerManf A. Pete¶s name pp areaCode phones holds. beersLiked. phones.

using 4NF violation X pp Y. but not for finding keys. so 4NF is more stringent than BCNF. then X is a superkey. X p Y implies X pp Y.Eliminate redundancy due to multiplicative effect of MVD¶s. R X Y . ± Remember. 4NF Roughly: treat MVD¶s as FD's for decomposition. into XY and X (R²Y). and X Y is not all attributes). Formally: R is in Fourth Normal Form if whenever MVD X pp Y is nontrivial (Y is not a subset of X. Decompose R.

Successive decomposition yields 4NF relations: D1(name. Only key: {name. beersLiked) FD: name p addr Nontrivial MVD¶s: name pp phones and name pp beersLiked.Drinkers(name. addr) D2(name. beersLiked) Example . phones. beersLiked} All three dependencies above violate 4NF. addr. phones. phones) D3(name.

HIGHER NORMAL FORMS 1NF 2NF 3NF BCNF 4NF 5NF functional dependencies multivalued dependencies join dependencies .

ALL FLIGHTS EVERY DAY ALL PLANES TAKE-OFF AND LAND (BUT DO NOT CRASH) NO AIRPORT IS LANDING-ONLY & NO AIRPORT IS TAKE-OFF-ONLY p T TTAB (ORG) = T TTAB (DST) THERE IS AT LEAST ONE TIME DELAY ENTRY FOR EVERY FLIGHT SIMILARLY IN WEATHER REPORT HISTORY IF NO TWO FLIGHTS CAN TAKE OFF AT THE SAME TIME IN THE SAME AIRPORT WES CAN BE POSTED TO FLIGHT AND WEATHER@ORIGIN ELIMINATED .ASSUMPTIONS 24-HOUR FLIGHT-TIMETABLE.

Computing) = true awards (NewCit . DEGREE) Computing Computing teaches (NewCit . DISCIPLINE) is_read_for (DISCIPLINE.AWARD UNIVERSITY Old Town Old Town New Cit Old Town DISCIPLINE DEGREE Computing Mat matics BSc PhD PhD PhD teaches (UNIVERSITY. BSc) = true FROM (NewCit teaches Computing) and (Computing is_read_for BSc) IT DOES NOT FOLLOW NewCit awards BSc for_reading Computing . DEGREE) awards (UNIVERSITY. PhD) = true is_read_for (Computing.

AWARD UNIVERSITY Old Town Old Town New City DISCIPLINE Computing Mathematics Computing DISCIPLINE Computing Mathematics Computing DEGREE UNIVERSITY DEGREE BSc PhD PhD Old Town Old Town New City BSc PhD PhD UNIVERSITY Old Town Old Town Old Town New City New City DISCIPLINE Computing Computing Mathematics Computing Computing DEGREE BSc PhD PhD BSc PhD spurious tuple UNIVERSITY Old Town Old Town Old Town New City DISCIPLINE Computing Computing Mathematics Computing DEGREE BSc PhD PhD PhD .

... ... R2. R2.a projection of R for if then JD*( holds for R ) .Join Dependency JD * (R1. Rm ). R3.. . Rm) holds in R iff R = join (R1. R3. Ri .

Rm) in R. every Ri is a superkey for R.. ) ) .Fifth Normal Form R preventing illogical conjunction of facts A relation R is in 5NF iff for all JD * (R1. .. R3.. . does not contain key then R is not in 5NF ) holds for R if JD* ( JD* ( then R is in 5NF . R2. if JD* ( .

AWARD UNIVERSITY DISCIPLINE DISCIPLINE DEGREE UNIVERSITY DEGREE Old Town Computing Computing BSc Old Town BSc Old Town Mathematics Mathematics PhD Old Town PhD New Cit Computing Computing PhD New Cit PhD .

. (NAME... CODE....... CODE).. RESEARCH)) JD2 * ((NAME. RESEARCH)) JD4 * ((NAME............... TEACHING).... (CODE. TEACHING)) JD5 * ((NAME...to JD5 are superkeys for RANKING p 5NF ...RESEARCH)) .... (NAME... TEACHING)..... (CODE.... all projections in JD1 ... RESEARCH)......NAME or CODE join dependencies JD1 * ((NAME..... CODE.......... CODE... TEACHING)) JD3 * ((NAME... (CODE....... CODE.... RESEARCH)..........RANKING NAME Ol T w New City CODE 05 C01 TEACHING 21 23 RESEARCH 4 3 candidate keys ..... (NAME... TEACHING)..

- FA14_CIVE_7397_Homework_1.pdf
- Classical Ciphers
- data-0001-fdbffe842be3e971012be71ed7e86b5d
- In Duc
- Math 10 Regents Midterm Review
- Integration-Area Under a Curve
- HW2.sol
- IPSC_ booklet
- Gate Maths Syllabus 2013
- Appendix d - The Associated Legendre Equation
- 02_Introduction2
- Torpedo Manual
- General Basic Coding
- A2T-ImaginaryNumbers
- Lecture 3 - Interpolation
- Cap02_Apostol T. M. - Mathematical Analysis
- Welcome to Algebra
- 4-4
- m24s12day7solnsWEB
- Finding e i Gen Vectors
- midpoint circle
- Information Theory Notes
- Generalization of Andrica's Conjecture, by Florentin Smarandache
- Formal Proof - Getting Started
- hw3
- 1.2 Matrices notes presentation
- Ex 1 Solutions
- Def- Laplace Transform
- Chapter 1

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd