You are on page 1of 22

Module 29

Partha Pratim
Das

Objectives &
Outline Database Management Systems
Multivalued
Dependency Module 29: Relational Database Design/9: MVD and 4NF
Definition
Example
Use
Theory

Decomposition to Partha Pratim Das


4NF

Module Summary
Department of Computer Science and Engineering
Indian Institute of Technology, Kharagpur

ppd@cse.iitkgp.ac.in

Database Management Systems Partha Pratim Das 29.1


Module Recap PPD

Module 29

Partha Pratim • Using the specification for a Library Information System, we have illustrated how a
Das
schema can be designed and then refined for finalization
Objectives &
Outline

Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.2


Module Objectives PPD

Module 29

Partha Pratim • To understand multi-valued dependencies arising out of attributes that can have
Das
multiple values
Objectives &
Outline • To define Fourth Normal Form and learn the decomposition algorithm to 4NF
Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.3


Module Outline PPD

Module 29

Partha Pratim • Multivalued Dependencies


Das
• Decomposition to 4NF
Objectives &
Outline

Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.4


MVD

Module 29

Partha Pratim
Das

Objectives &
Outline

Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary
Multivalued Dependency

Database Management Systems Partha Pratim Das 29.5


MVD: Multivalued Dependency PPD

Module 29 • Persons(Man, Phones, Dog Like)


Partha Pratim
Das

Objectives &
Outline

Multivalued
Dependency
Definition
Example
There are no non trivial FDs because all attributes are
Use combined forming Candidate Key, that is, MDP. In the
Theory

Decomposition to
above relation, two multivalued dependencies exists:
4NF
• Man  Phones
Module Summary
• Man  Dogs Like
A man’s phone are independent of the dogs they like.
But after converting the above relation in Single Valued
Attribute, each of a man’s phones appears with each of
the dogs they like in all combinations.
Source: http://www.edugrabs.com/multivalued-dependency-mvd/

Database Management Systems Partha Pratim Das 29.6


MVD (2) PPD

Module 29
• If two or more independent relations are kept in a single relation, then Multivalued
Partha Pratim
Das Dependency is possible. For example, Let there are two relations :
Objectives &
◦ Student(SID, Sname) where (SID → Sname)
Outline
◦ Course(CID, Cname) where (CID → Cname)
Multivalued
Dependency • There is no relation defined between Student and Course. If we kept them in a single
Definition
Example relation named Student Course, then MVD will exists because of m:n Cardinality
Use
Theory • If two or more MVDs exist in a relation, then while converting into SVAs, MVD exists.
Decomposition to
4NF

Module Summary

Source: http://www.edugrabs.com/multivalued-dependency-mvd/

Database Management Systems Partha Pratim Das 29.7


MVD (3)

Module 29

Partha Pratim
• Suppose we record names of children, and phone numbers for instructors:
Das
◦ inst child(ID, child name)
Objectives & ◦ inst phone(ID, phone number)
Outline

Multivalued
• If we were to combine these schema to get
Dependency
◦ inst info(ID, child name, phone number)
Definition
Example
◦ Example data:
Use (99999, David, 512-555-1234)
Theory (99999, David, 512-555-4321)
Decomposition to (99999, William, 512-555-1234)
4NF
(99999, William, 512-555-4321)
Module Summary
• This relation is in BCNF
◦ Why?

Database Management Systems Partha Pratim Das 29.8


MVD: Definition PPD

Module 29
• Let R be a relation schema and let α ⊆ R and β ⊆ R. The multivalued dependency
Partha Pratim
Das αβ
Objectives &
holds on R if in any legal relation r(R), for all pairs for tuples t1 and t2 in r such that
Outline t1 [α] = t2 [α], there exist tuples t3 and t4 in r such that:
Multivalued
Dependency
Definition
t1 [α] = t2 [α] = t3 [α] = t4 [α]
Example t3 [β] = t1 [β]
Use t3 [R – β] = t2 [R – β] Test: course  book
Theory
t4 [β] = t2 [β]
Decomposition to t4 [R – β] = t1 [R – β]
4NF

Module Summary

Example: A relation of university


courses, the books recommended for
the course, and the lecturers who
will be teaching the course:
• course  book
• course  lecturer
Database Management Systems Partha Pratim Das 29.9
MVD: Example

Module 29

Partha Pratim
• Let R be a relation schema with a set of attributes that are partitioned into 3 nonempty subsets.
Das Y, Z, W
Objectives & • We say that Y  Z (Y multidetermines Z ) if and only if for all possible relations r (R )
Outline < y1 , z1 , w1 >∈ r and < y1 , z2 , w2 >∈ r
Multivalued then
Dependency
Definition
< y1 , z1 , w2 >∈ r and < y1 , z2 , w1 >∈ r
Example
Use
• Note that since the behavior of Z and W are identical it follows that
Theory
Y  Z if Y  W
Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.10


MVD: Example (2)

Module 29

Partha Pratim • In our example:


Das
ID  child name
Objectives &
Outline
ID  phone number
Multivalued • The above formal definition is supposed to formalize the notion that given a particular
Dependency
Definition value of Y (ID) it has associated with it a set of values of Z (child name) and a set of
Example
Use
values of W (phone number ), and these two sets are in some sense independent of
Theory each other.
Decomposition to
4NF • Note:
Module Summary ◦ If Y → Z then Y  Z
◦ Indeed we have (in above notation) Z1 = Z2
The claim follows.

Database Management Systems Partha Pratim Das 29.11


MVD: Use

Module 29

Partha Pratim • We use multivalued dependencies in two ways:


Das
a) To test relations to determine whether they are legal under a given set of
Objectives &
Outline functional and multivalued dependencies
Multivalued b) To specify constraints on the set of legal relations. We shall thus concern ourselves
Dependency
Definition
only with relations that satisfy a given set of functional and multivalued
Example
Use
dependencies.
Theory
• If a relation r fails to satisfy a given multivalued dependency, we can construct a
Decomposition to
4NF relations r ’ that does satisfy the multivalued dependency by adding tuples to r.
Module Summary

Database Management Systems Partha Pratim Das 29.12


MVD: Theory PPD

Module 29

Partha Pratim Name Rule


Das
C- Complementation If X  Y , then X  (R − (X ∪ Y )).
Objectives & A- Augmentation If X  Y and W ⊇ Z , then WX  YZ .
Outline
T- Transitivity If X  Y and Y  Z , then X  (Z − Y ).
Multivalued
Dependency Replication If X → Y , then X  Y but the reverse is not true.
Definition Coalescence If X  Y and there is a W such that
Example
W ∩ Y is empty, W → Z and Y ⊇ Z , then X → Z .
Use
Theory

Decomposition to • A MVD X  Y in R is called a trivial MVD is


4NF

Module Summary
◦ Y is a subset of X (X ⊇ Y) or
◦ X ∪ Y = R. Otherwise, it is a non trivial MVD and we have to repeat values
redundantly in the tuples.

Database Management Systems Partha Pratim Das 29.13


MVD: Theory (2)

Module 29
• From the definition of multivalued dependency, we can derive the following rule:
Partha Pratim
Das ◦ If α → β, then α  β
Objectives & That is, every functional dependency is also a multivalued dependency
Outline

Multivalued
• The closure D + of D is the set of all functional and multivalued dependencies logically
Dependency
Definition
implied by D.
Example
◦ We can compute D + from D, using the formal definitions of functional
Use
Theory dependencies and multivalued dependencies.
Decomposition to
4NF
◦ We can manage with such reasoning for very simple multivalued dependencies,
Module Summary
which seem to be most common in practice
◦ For complex dependencies, it is better to reason about sets of dependencies using a
system of inference rules

Database Management Systems Partha Pratim Das 29.14


Decomposition to 4NF PPD

Module 29

Partha Pratim
Das

Objectives &
Outline

Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary
Decomposition to 4NF

Database Management Systems Partha Pratim Das 29.15


Fourth Normal Form

Module 29
• A relation schema R is in 4NF with respect to a set D of functional and multivalued
Partha Pratim
Das dependencies if for all multivalued dependencies in D + of the form α  β, where α ⊆
Objectives &
R and β ⊆ R, at least one of the following hold:
Outline
◦ α  β is trivial (that is, β ⊆ α or α ∪ β = R)
Multivalued
Dependency ◦ α is a superkey for schema R
Definition
Example • If a relation is in 4NF it is in BCNF
Use
Theory

Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.16


Restriction of Multivalued Dependencies

Module 29
• The restriction of D to Ri is the set Di consisting of
Partha Pratim
Das ◦ All functional dependencies in D + that include only attributes of Ri
Objectives &
◦ All multivalued dependencies of the form
Outline
α  (β ∩ Ri )
Multivalued
Dependency where α ⊆ Ri and α  β is in D +
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary

Database Management Systems Partha Pratim Das 29.17


4NF Decomposition Algorithm PPD

Module 29

Partha Pratim a) For all dependencies A  B in D + , check if A is a superkey


Das
• By using attribute closure
Objectives &
Outline b) If not, then
Multivalued
Dependency • Choose a dependency in F+ that breaks the 4NF rules, say A  B
Definition
Example
• Create R1 = A B
Use • Create R2 = (R – (B – A))
Theory
• Note that: R1 ∩ R2 = A and A  AB (= R1), so this is lossless decomposition
Decomposition to
4NF
c) Repeat for R1, and R2
Module Summary
• By defining D1+ to be all dependencies in F that contain only attributes in R1
• Similarly D2+

Database Management Systems Partha Pratim Das 29.18


4NF Decomposition Algorithm

Module 29
result: = {R};
Partha Pratim
Das
done := false;
compute D + ;
Objectives & Let Di denote the restriction of D + to Ri
Outline
while ( not done)
Multivalued
Dependency
if (there is a schema Ri in result that is not in 4NF) then
Definition begin
Example let α  β be a nontrivial multivalued dependency that holds
Use
Theory
on Ri such that α → Ri is not in Di , and α ∩ β = φ ;
result := (result − Ri ) ∪ (Ri − β) ∪ (α, β);
Decomposition to
4NF end
Module Summary
else done:= true;
Note: each Ri is in 4NF, and decomposition is lossless-join

Database Management Systems Partha Pratim Das 29.19


Example of 4NF Decomposition PPD

Module 29
• Example:
Partha Pratim
Das ◦ Person Modify(Man(M), Phones(P), Dog Likes(D),
Address(A)) Post Normalization
Objectives &
Outline ◦ FDs:
Multivalued . FD1 : Man  Phones
Dependency
Definition
Example
. FD2 : Man  Dogs Like
Use
Theory . FD3 : Man → Address
Decomposition to
4NF
◦ Key = MPD
Module Summary
◦ All dependencies violate 4NF

Database Management Systems Partha Pratim Das 29.20


Example of 4NF Decomposition

Module 29
• R =(A, B, C, G, H, I)
Partha Pratim
Das F=AB
Objectives &
B  HI
Outline CG  H
Multivalued
Dependency • R is not in 4NF since A  B and A is not a superkey for R
Definition
Example • Decomposition
Use
Theory
a) R1 = (A, B) (R1 is in 4NF)
Decomposition to b) R2 = (A, C, G, H, I) (R2 is not in 4NF, decompose into R3 and R4 )
4NF
c) R3 = (C, G, H) (R3 is in 4NF)
Module Summary
d) R4 = (A, C, G, I) (R4 is not in 4NF, decompose into R5 and R6 )
◦ A  B and B  HI → A  HI, (MVD transitivity), and
◦ and hence A  I (MVD restriction to R4 )
e) R5 = (A, I) (R5 is in 4NF)
f) R6 = (A, C, G) (R6 is in 4NF)

Database Management Systems Partha Pratim Das 29.21


Module Summary

Module 29

Partha Pratim • Understood multi-valued dependencies to handle attributes that can have multiple
Das
values
Objectives &
Outline • Learnt Fourth Normal Form and decomposition to 4NF
Multivalued
Dependency
Definition
Example
Use
Theory

Decomposition to
4NF

Module Summary

Slides used in this presentation are borrowed from http://db-book.com/ with kind
permission of the authors.
Edited and new slides are marked with “PPD”.

Database Management Systems Partha Pratim Das 29.22

You might also like