relational design theory boyce-codd normal formrelational design by decomposition “mega”...

15
Jennifer Widom Relational Design Theory Boyce-Codd Normal Form

Upload: others

Post on 18-Mar-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Relational Design Theory

Boyce-Codd Normal Form

Page 2: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Relational design by decomposition

“Mega” relations + properties of the data System decomposes based on properties Final set of relations satisfies normal form

– No anomalies, no lost information

Functional dependencies Boyce-Codd Normal Form Multivalued dependences Fourth Normal Form

BCNF

Page 3: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Decomposition of a relational schema

BCNF

Page 4: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Decomposition Example #1

Student(SSN, sName, address, HScode, HSname, HScity, GPA, priority)

BCNF

Page 5: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Decomposition Example #2

Student(SSN, sName, address, HScode, HSname, HScity, GPA, priority)

BCNF

Page 6: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Relational design by decomposition

“Mega” relations + properties of the data System decomposes based on properties

“Good” decompositions only Into “good” relations

BCNF

Page 7: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Boyce-Codd Normal Form

Relation R with FDs is in BCNF if: For each Ᾱ B, Ᾱ is a key

BCNF

Page 8: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

BCNF? Example #1

Student(SSN, sName, address, HScode, HSname, HScity, GPA, priority)

SSN sName, address, GPA

GPA priority

HScode HSname, HScity

BCNF

Page 9: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

BCNF? Example #2

Apply(SSN, cName, state, date, major)

SSN, cName, state date, major

BCNF

Page 10: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Relational design by decomposition

“Mega” relations + properties of the data System decomposes based on properties

“Good” decompositions only Into “good” relations

BCNF

Page 11: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

BCNF decomposition algorithm

Input: relation R + FDs for R Output: decomposition of R into BCNF relations with “lossless join”

Compute keys for R

Repeat until all relations are in BCNF:

Pick any R’ with A B that violates BCNF

Decompose R’ into R1(A, B) and R2(A, rest)

Compute FDs for R1 and R2

Compute keys for R1 and R2

BCNF

Page 12: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

BCNF Decomposition Example Student(SSN, sName, address, HScode, HSname, HScity,

GPA, priority)

SSN sName, address, GPA GPA priority

HScode HSname, HScity

BCNF

Page 13: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

BCNF decomposition algorithm

Input: relation R + FDs for R Output: decomposition of R into BCNF relations with “lossless join”

Compute keys for R

Repeat until all relations are in BCNF:

Pick any R’ with A B that violates BCNF

Decompose R’ into R1(A, B) and R2(A, rest)

Compute FDs for R1 and R2

Compute keys for R1 and R2

BCNF

Page 14: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Does BCNF guarantee a good decomposition?

Removes anomalies? Can logically reconstruct original relation?

Too few or too many tuples?

BCNF

Page 15: Relational Design Theory Boyce-Codd Normal FormRelational design by decomposition “Mega” relations + properties of the data System decomposes based on properties Final set of relations

Jennifer Widom

Does BCNF guarantee a good decomposition?

Removes anomalies? Can logically reconstruct original relation?

Too few or too many tuples?

Some shortcomings discussed in later video

BCNF