announcements read 6.1 – 6.3 for wednesday project step 3, due now homework 5, due friday 10/22...

26
Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper List of sources - due 10/29

Upload: diane-foulk

Post on 14-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Announcements

• Read 6.1 – 6.3 for Wednesday

• Project Step 3, due now

• Homework 5, due Friday 10/22

• Project Step 4, due Monday

• Research paper– List of sources - due 10/29

Page 2: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Normalization

Lecture 14

Page 3: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Algorithmic Test for Lossless Join

Given a relation R(A1, A2, …, An), a set of functional dependencies, F, and a decomposition of R into relations R1, R2, …, Rm

1. Construct an m by n table S, with a column for each of the n attributes in R and a row for each of the m relations in the decomposition

2. For each cell S(i,j) of S,If the attribute for the column, Aj, is in the relation for

the row, Ri, then place the symbol a(j) in the cell; else place the symbol b(i,j) there

Page 4: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Algorithmic Test for Lossless Join (Continued)

3. Repeat the following process until no more changes can be made to S:

For each FD X → Y in FFor all rows in S that have the same symbols in the columns

corresponding to the attributes of X, make the symbols for the columns that represent the attributes of Y equal by the following rule:if any row has an a value, a(j), then set the value of that column in all

other rows equal to a(j)if no row has an a value, then pick any one of the b values, say b(i,j),

and all the other rows equal to b(i,j)

4. If, after all possible changes have been made to S, a row is made up entirely of a symbols, a(1), a(2), …, a(n), then the join is lossless. It there is no such row, the join is lossy.

Page 5: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

R = {SSN, ENAME, PNUMBER, PNAME, PLOCATION, HOURS}R1 = EMP_LOCS={ENAME, PLOCATION}R2 = EMP_PROJ1={SSN, PNUMBER, HOURS, PNAME, PLOCATION}

F={SSN→ENAME; PNUMBER→{PNAME, PLOCATION}; {SNN, PNUMBER}→HOURS

SSN ENAME PNUMBER PNAME PLOCATION HOURS

R1

R2

Page 6: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

R = {SSN, ENAME, PNUMBER, PNAME, PLOCATION, HOURS}R1 = EMP={SSN, ENAME}R2 = PROJ={PNUMBER, PNAME, PLOCATION}R3 = WORKS_ON={SSN, PNUMBER, HOURS}

F={SSN→ENAME; PNUMBER→{PNAME, PLOCATION}; {SNN, PNUMBER}→HOURS

SSN ENAME PNUMBER PNAME PLOCATION HOURS

R1

R2

R3

Page 7: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Lossless Projections• Lossless property guaranteed if for each pair of

relations that will be joined, the set of common attributes is a superkey of one of the relations

• Binary decomposition of R into {R1,R2} has the lossless join property with respect to a set of functional dependencies F on R iff one of these holds

The FD ((R1 ∩ R2) → (R1 - R2)) is in F+

or The FD (( R1 ∩ R2) → (R2 - R1 )) is in F+

• If projection is done by successive binary projections, can apply binary decomposition test repeatedly

Page 8: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Multi-valued Dependency• In R(A,B,C) if each A values has associated with it

a set of B values and a set of C values such that the B and C values are independent of each other, then

• Multi-valued dependencies• Example: JointAppoint(facId, dept, committee)

assuming a faculty member can belong to more than one department and belong to more than one committee

Page 9: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

4NF

• A table is 4NF if

• Example: remove MVDs in JointAppoint

Page 10: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

5NF and DKNF

• A relation is 5NF

• A relation is in Domain-Key Normal Form (DKNF)

Page 11: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

De-normalization

• When to stop the normalization process–

Page 12: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Inference Rules for FDs

• Armstrong’s Axioms– Reflexivity – Augmentation– Transitivity

Additional rules that follow:– Additivity– Projectivity– Pseudotransitivity

Page 13: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Closure of Set of FDs

• If F is a set of functional dependencies for a relation R, then the set of all functional dependencies that can be derived from F, F+, is called the closure of F

• Could compute closure by applying Armstrong’s Axioms repeatedly

Page 14: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Closure of an Attribute• If A is an attribute or set of attributes of relation R,

all the attributes in R that are functionally dependent on A in R form the closure of A, A+

• Computed by Closure Algorithm for A, Section 5.7.3result ← A;while (result changes) do

for each functional dependency B → C in F if B is contained in result then result ← result C;end;A+ ← result;

Page 15: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources
Page 16: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Uses of Attribute Closure

• Can determine if A is a superkey-

• Can determine whether a given FD X→Y is in the closure of the set of FDs. (Find X+, see if it includes Y)

Page 17: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Redundant FDs

• Given a set of FDs, can determine if any of them is redundant, i.e. can be derived from the remaining FDs, by a simple algorithm

Page 18: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Algorithm for Determining Redundancy

1. Choose a candidate FD, say X → Y, and remove it from the set of FDs

2. result ← X;while (result changes and Y is not contained in

result) dofor each FD, A → B, remaining in the reduced set of FDs

If A is a subset of result, then result ← result B

end3. if Y is a subset of result, then the FD X → Y

is redundant

Page 19: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources
Page 20: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Covers

• If a relation R has two sets of FDs, F and G– then F is a cover for G if every FD in G is

also in F+

– F and G are equivalent if F is a cover for G and G is a cover for F (i.e. F+ = G+)

Page 21: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Minimal Set of FDs

• Set of FDs, F is minimal if–

Page 22: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Minimal Cover for Set of FDs

• A minimal cover for a set of FDs is a cover such that no proper subset of itself is also a cover

• A set of FDs may have several minimal covers

Page 23: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Algorithm for Finding Minimal Cover1. Set F ← G2. For each FD in F that is not in canonical form, i.e. of the

form X → {Y1, Y2, …, Yn}, replace if by the n FDs X → Y1, X → Y2, …, X → Yn;

3. Eliminate extraneous attributed:For each FD X → Y in F

for each attribute A that is an element of Xif ((F-{X → Y}) U {(X – {A}) → Y} is equivalent to Fthen replace X → Y with (X – {A}) → Y in F;

4. Eliminate redundant FDs:For each remaining FD X → Y in F

if (F – {X → Y}) is equivalent to Fthen remove X → Y from F

Page 24: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources
Page 25: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Decomposition Algorithm for BCNF

• Can always find a lossless decomposition that is BCNF– Find a FD that is a violation of BCNF and remove

it by decomposition process– Repeat this process until all violations are

removed

• No need to go through 1NF, 2NF, 3NF process

• Not always possible to preserve all FDs

Page 26: Announcements Read 6.1 – 6.3 for Wednesday Project Step 3, due now Homework 5, due Friday 10/22 Project Step 4, due Monday Research paper –List of sources

Synthesis Algorithm for 3NF

• Can always find 3NF decomposition that is lossless and that preserves all FDs

• 3NF Algorithm uses synthesis– Begin with universal relation and set of FDs,G– Find a minimal cover for G– Combine FDs that have the same determinant– Include a relation with a key of R– Algorithm in the book, p. 260