Presentation is loading. Please wait.

Presentation is loading. Please wait.

4NF. PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…)

Similar presentations


Presentation on theme: "4NF. PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…)"— Presentation transcript:

1 4NF

2 PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…) MWorks(workcode,…) Authorized(sin,model,workcode) MServices(servno,regno,…) States(state) Dates(datereached) Assignment(servno, workcode, sin, state, datereached) Project (fragment)

3 Problem Assignment(servno, workcode, sin, state, datereached) servnoworkcodesinstatedatereached 1engine111-111-111127/03/2008 1engine222-222-222127/03/2008 1engine333-333-333127/03/2008 1engine111-111-111228/03/2008 1engine222-222-222228/03/2008 1engine333-333-333228/03/2008 1engine111-111-111329/03/2008 1engine222-222-222329/03/2008 1engine333-333-333329/03/2008

4 Problem Assignment(servno, workcode, sin, state, datereached) We might assert one FD: servno workcode state  datereached(functional dependency) However, this FD doesn’t really help here! Problem In this table, employee's sin numbers are independent of the states. Thus, for any existing servno, workcode pair, say (s,w), the sin numbers of employees assigned to (s,w) appear with each of the states that (s,w) reaches in all the combinations.

5 Tuples Implied by Independence If we have the blue tuples: servnoworkcodesinstatedate_reached 1engine111-111-111127/03/2008 1engine222-222-222127/03/2008 1engine333-333-333127/03/2008 1engine111-111-111228/03/2008 1engine222-222-222228/03/2008 1engine333-333-333228/03/2008 1engine111-111-111329/03/2008 1engine222-222-222329/03/2008 1engine333-333-333329/03/2008 Then the red tuples must also be in the relation.

6 Definition of MVD A multivalued dependency (MVD), denoted by X ->->Y is an assertion that: If two tuples agree on all the attributes of X, then their Y-components may be swapped, and the result will be two tuples that are also in the relation.

7 Example Example servno, workcode, sin, state illustrated MVD servno workcode ->-> sin and the MVD servno workcode ->-> state

8 Picture of MVD X ->->Y XY others equal exchange

9 FDs vs. MVDs Every FD is an MVD. –If X ->Y, then swapping Y ’s between two tuples that agree on X doesn’t change the tuples. –Therefore, the “new” tuples are surely in the relation, and we know X ->->Y.

10 Fourth Normal Form The redundancy that comes from MVD’s is not removable by putting the database schema in BCNF. There is a stronger normal form, called 4NF, that (intuitively) treats MVD’s as FD’s when it comes to decomposition.

11 4NF Definition A relation R is in 4NF if whenever X ->->Y is a nontrivial MVD, then X is a superkey. –"Nontrivial" means that: 1.Y is not a subset of X, and 2.X and Y are not, together, all the attributes. –Note that the definition of “superkey” still depends on FD’s only.

12 BCNF Versus 4NF Remember that every FD X ->Y is also an MVD, X ->->Y. Thus, if R is in 4NF, it is certainly in BCNF. –Because any BCNF violation is a 4NF violation. But R could be in BCNF and not 4NF, because MVD’s are “invisible” to BCNF.

13 Decomposition and 4NF If X ->->Y is a 4NF violation for relation R, we can decompose R using the same technique as for BCNF. 1.XY is one of the decomposed relations. 2.The other relation has X and all the other attributes of R that are not in X or Y.

14 Example Assignment(servno, workcode, sin, state, datereached) FD: servno workcode state  datereached MVDs: servno, workcode ->-> sin servno, workcode ->-> state Key is {servno, workcode, sin, state} All dependencies violate 4NF.

15 Example, Continued Decompose using servno workcode state  datereached : Assignment1(servno,workcode,state,datereached) uIn 4NF. Assignment2(servno,workcode,sin,state) uNot in 4NF. MVD’s servno, workcode ->-> sin servno, workcode ->-> state apply. No FD’s, so all four attributes form the key.

16 Example: Decompose Assignment2 Either MVD servno, workcode ->-> sin servno, workcode ->-> state tells us to decompose to: Assignment3(servno,workcode,sin) Assignment4(servno,workcode,state) The last one (Assignment4) is completely contained in Assignment1, and thus, not needed.


Download ppt "4NF. PTypes Planes HasType Employees MServices Auth. MWorks Assignment AppliedOn States Dates PTypes(model, capacity,…) Planes(regno, model) Employees(sin,…)"

Similar presentations


Ads by Google