Relational Database Design
Relational Database Design
Insertion anomalies
Deletion anomalies
Modification anomalies
Insert Anomaly: Cannot insert a project unless an
employee is assigned to .
Inversely - Cannot insert an employee unless an
he/she is assigned to a project.
Update anomalies − If data items are scattered and are not linked
to each other properly, then it could lead to strange situations. For
example, when we try to update one data item having its copies
scattered over several places, a few instances get updated properly
while a few others are left with old values. Such instances leave the
database in an inconsistent state.
There is a FD from X to Y or Y is FD on X
FD=> Functional dependency or f.d
X=> L.H.S
Y=> R.H.S
Full Functional dependency
Partial Functional dependency
Transitive dependency
Normal forms
1NF, 2NF, 3NF, BCNF(Boyce Codd Normal
Form),4NF and 5NF
1NF- is based on primary key and atomic values and there
must be no composite attributes, multivalued attributes and
relation with in relation.
Composite attribute
FD = {{eno,pno}-> hours,
eno->ename
pno->pname, plocation}
R1={eno,pno,hours}
R2 = {eno,ename}
R3={pno,pname,plocation}
now all the relations R1, R2 and R3 are in full functional
dependency.
3NF-
It is based on the concept of transitive dependency
Def: A rs R is in 3NF if it satisfies 2 NF and no non
prime attribute of R is transitively dependent on the
primary key
R1={eno,ename,address,dno} R2 = {dno,dname}
BCNF(Boyce codd Normal Form)
Def:
A rs R is in BCNF if when ever a non trivial FD
X-> A holds in R, then X is a super key of R
Closure of a Set of Functional
Dependencies
Closure of a Set of Attributes
Redundancy of FDs
Equivalence of sets of FDs
⚫ Two sets of FDs E and F
⚫ F is said to cover E if every FD in E is also in
closure of F
⚫ E and F are equivalent
⚫ if E covers F and F covers E
⚫ E+ = F+
Equivalence of FD
Equivalence of F.D: If the two set of Functional dependency F1 and
F2, defined by data base designers for the same problem domain.
They are considered to be equivalent if closure of F1=Closure of
F2.
Ex. Consider the below two relations F and G
F={B->CDE,AD->E,B->A} G={B->CD,B->ABC,AD->E}
Solution:
➢ Take G and compute closure for B+, AD+ from F.
X=B=BCD=BCAD=BCDAE=ABCDE
X=AD=ADE
➢ Take F and compute closure for B+, AD+ from G
X=B=BCDE=ABCDE=ABCDEE=ABCDE
X=AD=ADE
F+ = G+
Canonical Cover
Example of Computing a
Canonical Cover
Finding Keys
3. Multivalued Dependencies and Fourth Normal Form
(a) The EMP relation with two MVDs: ENAME —>> PNAME and ENAME —>> DNAME.
(b) Decomposing the EMP relation into two 4NF relations EMP_PROJECTS and EMP_DEPENDENTS.
Multivalued Dependencies and Fourth Normal Form
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
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.
Multivalued Dependencies and Fourth Normal Form
Decomposing a relation state of EMP that is not in 4NF.
(a) EMP relation with additional tuples.
(b) Two corresponding 4NF relations EMP_PROJECTS and EMP_DEPENDENTS.
4. Join Dependencies and Fifth Normal Form (1)
Definition:
⚫ A join dependency (JD), denoted by JD(R1, R2, ..., Rn),
specified on relation schema R, specifies a constraint on the
states r of R. The constraint states that every legal state r of R
should have a non-additive join decomposition into R1, R2, ...,
Rn; that is, for every such r we have
* (ΠR1(r), Π R2(r), ..., ΠRn(r)) = r
AB->CD
The above functional dependency should be
decomposed to singleton attributes in the RHS as below.
AB-> C and
AB-> D
Identify extraneous attributes and remove it