Session 21-24 Modified
Session 21-24 Modified
FUNCTIONAL DEPENDENCIES
NORMALIZATION AND NORMAL
FORMS
Session 21
SECOND NORMAL FORM,
TRANSITIVE DEPENDENCIES
Definitions of Keys and Attributes
Participating in Keys (1)
A superkey of a relation schema R = {A1, A2, ....,
An} is a set of attributes S subset-of R with the
property that no two tuples t1 and t2 in any legal
relation state r of R will have t1[S] = t2[S]
sol:
from given dependencies
a and d are on left side (which determines other attributes )
bce are on the right side (which are dependents)
so check the following
aa not key
dd not key
adad not key
(ab)(ab)c not key
(abd)(abd)ce yes , this dependency satisfies the key rule
Consider the following relation: CAR_SALE (Car_id, Option_type,
Option_listprice, Sale_date, Option_discountedprice) This relation refers to
options installed in cars (e.g., cruise control) that were sold at a dealership,
and the list and discounted prices of the options.
If CarID → Sale_date and Option_type → Option_listprice and CarID,
Option_type → Option_discountedprice, argue using the generalized
definition of the 3NF that this relation is not in 3NF. Then argue from your
knowledge of 2NF, why it is not even in 2NF.
Sol :
we can assume the data as simple attribute and assume the relation is in 1NF as no
data is specified.
Check partial dependencies
CARID SALE_DATE ----------------------------------------------- PARTIAL FD
OPTION_TYPE → OPTION_LISTPRICE ----------------------- PARTIAL FD
CARID, OPTION_TYPE → OPTION_DISCOUNTEDPRICE-------- FULL FD
SO, the given relation CAR_SALE is not in 2nf because there are two partial
functional dependencies.
Normalization into 2NF and 3NF
Figure 14.13
Boyce-Codd normal form. (a) BCNF normalization of LOTS1A with the
functional dependency FD2 being lost in the decomposition. (b) A schematic
relation with FDs; it is in 3NF, but not in BCNF due to the f.d. C → B.
Figure A relation TEACH that is in 3NF
but not in BCNF
Figure 14.14
A relation TEACH that is in 3NF
but not BCNF.
Achieving the BCNF by Decomposition (1)
Two FDs exist in the relation TEACH:
fd1: { student, course} -> instructor
fd2: instructor -> course
{student, course} is a candidate key for this relation and
that the dependencies shown follow the pattern in Figure
14.13 (b).
So this relation is in 3NF but not in BCNF
A relation NOT in BCNF should be decomposed so as to
meet this property, while possibly forgoing the
preservation of all functional dependencies in the
decomposed relations.
(See Algorithm 15.3)
Achieving the BCNF by Decomposition (2)
Three possible decompositions for relation TEACH
D1: {student, instructor} and {student, course}
Instructor Student.
Since Instructor Course is indeed true, the NJB
property is satisfied and D3 is determined as a non-
additive (good) decomposition.
General Procedure for achieving BCNF
when a relation fails BCNF
Here we make use the algorithm from Chapter 15
(Algorithm 15.5):
Let R be the relation not in BCNF, let X be a subset-of R,
and let X A be the FD that causes a violation of BCNF.
Then R may be decomposed into two relations:
(i) R –A and (ii) X υ A.
If either R –A or X υ A. is not in BCNF, repeat the process.
Note that the f.d. that violated BCNF in TEACH was Instructor Course.
Hence its BCNF decomposition would be :
(TEACH – COURSE) and (Instructor υ Course), which gives
the relations: (Instructor, Student) and (Instructor, Course) that we obtained
before in decomposition D3.
SESSION 23
MULTIVALUED
DEPENDENCIES AND FOURTH
NORMAL FORM (1)
Multivalued Dependencies and Fourth Normal
Form (1)
Definition:
A multivalued dependency (MVD) X —>> Y specified on relation
schema R, where X and Y are both subsets of R, specifies the
following constraint on any relation state r of R: If two tuples t1 and
t2 exist in r such that t1[X] = t2[X], then two tuples t3 and t4 should
also exist in r with the following properties, where we use Z to
denote (R 2 (X υ Y)):
t3[X] = t4[X] = t1[X] = t2[X].
t3[Y] = t1[Y] and t4[Y] = t2[Y].
t3[Z] = t2[Z] and t4[Z] = t1[Z].
An MVD X —>> Y in R is called a trivial MVD if (a) Y is a subset of
X, or (b) X υ Y = R.
Multivalued Dependencies and Fourth Normal
Form (3)
Definition:
A relation schema R is in 4NF with respect to a set of
dependencies F (that includes functional dependencies
and multivalued dependencies) if, for every nontrivial
multivalued dependency X —>> Y in F+, X is a superkey
for R.
Note: F+ is the (complete) set of all dependencies
(functional or multivalued) that will hold in every relation
state r of R that satisfies F. It is also called the closure of
F.
Normalizing into 4NF
SESSION 24