You are on page 1of 28

BCNF ,4NF n 5NF

Boyce-Codd Normal Form


BCNF is perhaps the most useful Normal Form for database
design

A relation schema R is in BCNF with respect to a set F
of functional dependencies if for all functional
dependencies in F
+
of the form o |, where o _ R
and | _ R, at least one of the following holds:


o | is trivial (i.e., | _ o)
o is a superkey for R




Boyce-Codd Normal Form
(BCNF)
For each FD X->Y,
Rule 1: where Y is in X (Y _ X) or
Rule 2:where For every FD X-> Y, X has to be a superkey

Example of BCNF
Customer-schema = (c_name, c_street, c_city)
c_street -> c_street c_city
Is BCNF because of Rule 1
Loan-schema = (branch_name, c_name, loan_no, amount)
Is not BCNF because Rule 1 or Rule 2 are not satisfied
e.g., Loan_no -> amount, branch_name
Loan_no cannot be a superkey because wife and husband can create the
same Loan_no

Difference between Two Important
Normal Forms
Boyce-Codd Normal Form (BCNF). For every
relation scheme R and for every X A that holds
over R,
either A e X (it is trivial) ,or
or X is a superkey for R

Third Normal Form (3NF). For every relation
scheme R and for every X A that holds over R,
either A e X (it is trivial), or
X is a superkey for R, or
A is a member of some key for R
Example of BCNF
fd1 clientNo, interviewDate interviewTime, staffNo, roomNo (Primary Key)
fd2 staffNo, interviewDate, interviewTime clientNo (Candidate key)
fd3 roomNo, interviewDate, interviewTime clientNo, staffNo (Candidate key)
fd4 staffNo, interviewDate roomNo (not a candidate key)

As a consequece the ClientInterview relation may suffer from update anmalies.
For example, two tuples have to be updated if the roomNo need be changed for
staffNo SG5 on the 13-May-02.
ClientNo interviewDate interviewTime staffNo roomNo
CR76 13-May-02 10.30 SG5 G101
CR76 13-May-02 12.00 SG5 G101
CR74 13-May-02 12.00 SG37 G102
CR56 1-Jul-02 10.30 SG5 G102
Figure 8 ClientInterview relation
ClientInterview
Example of BCNF(2)
To transform the ClientInterview relation to BCNF, we must remove
the violating functional dependency by creating two new relations
called Interview and SatffRoom as shown below,

Interview (clientNo, interviewDate, interviewTime, staffNo)
StaffRoom(staffNo, interviewDate, roomNo)
ClientNo interviewDate interviewTime staffNo
CR76 13-May-02 10.30 SG5
CR76 13-May-02 12.00 SG5
CR74 13-May-02 12.00 SG37
CR56 1-Jul-02 10.30 SG5
staffNo interviewDate roomNo
SG5 13-May-02 G101
SG37 13-May-02 G102
SG5 1-Jul-02 G102
Interview
StaffRoom
Figure 9 BCNF Interview and StaffRoom relations
Eliminating Modification Anomalies from
Functional Dependencies in Relations
Put all relations into Boyce-Codd Normal Form
(BCNF):
Putting a Relation into BCNF:
EQUIPMENT_REPAIR
Putting a Relation into BCNF:
EQUIPMENT_REPAIR
EQUIPMENT_REPAIR (ItemNumber, Type, AcquisitionCost,
RepairNumber, RepairDate, RepairAmount)

ItemNumber (Type, AcquisitionCost)
RepairNumber (ItemNumber, Type, AcquisitionCost,
RepairDate, RepairAmount)

ITEM (ItemNumber, Type, AcquisitionCost)
REPAIR (ItemNumber, RepairNumber, RepairDate, RepairAmount)
Where REPAIR.ItemNumber must exist in
ITEM.ItemNumber
Putting a Relation into BCNF:
New Relations
Comparison of BCNF and 3NF
It is always possible to decompose a relation into relations
in 3NF such that:
the decomposition is lossless
the dependencies are preserved

It is always possible to decompose a relation into relations
in BCNF such that:
the decomposition is lossless
but it may not be possible to preserve dependencies
Multivaled Dependencies
A multivaled dependency occurs when a
determinant determines a particular set of
values:
Employee Degree
Employee Sibling
PartKit Part
The determinant of a multivaled
dependency can never be a primary key
Multivaled Dependencies
Eliminating Anomolies from
Multivaled Dependencies
Multivalued dependencies are not a problem
if they are in a separate relation, so:
Always put multivaled dependencies into their
own relation
This is known as Fourth Normal Form (4NF)
Use of Multivalued
Dependencies
We use multivalued dependencies in two
ways:
1. To test relations to determine whether they are
legal under a given set of functional and
multivalued dependencies
2. To specify constraints on the set of legal relations.
We shall thus concern ourselves only with
relations that satisfy a given set of functional and
multivalued dependencies.
If a relation r fails to satisfy a given
multivalued dependency, we can construct a
relations r' that does satisfy the multivalued
dependency by adding tuples to r.

Multivalued Dependencies
There are database schemas in BCNF that do not seem to
be sufficiently normalized
Consider a database
classes(course, teacher, book)
such that (c,t,b) e classes means that t is qualified to teach
c, and b is a required textbook for c
The database is supposed to list for each course the set of
teachers any one of which can be the courses instructor,
and the set of books, all of which are required for the
course (no matter who teaches it).
There are no non-trivial functional dependencies and
therefore the relation is in BCNF
Insertion anomalies i.e., if Sara is a new teacher that can
teach database, two tuples need to be inserted
(database, Sara, DB Concepts)
(database, Sara, Ullman)
course teacher book
database
database
database
database
database
database
operating systems
operating systems
operating systems
operating systems
Avi
Avi
Hank
Hank
Sudarshan
Sudarshan
Avi
Avi
Jim
Jim
DB Concepts
Ullman
DB Concepts
Ullman
DB Concepts
Ullman
OS Concepts
Shaw
OS Concepts
Shaw
classes
Multivalued Dependencies
Therefore, it is better to decompose classes
into:
course teacher
database
database
database
operating systems
operating systems
Avi
Hank
Sudarshan
Avi
Jim
teaches
course book
database
database
operating systems
operating systems
DB Concepts
Ullman
OS Concepts
Shaw
text
We shall see that these two relations are in Fourth Normal
Form (4NF)
Example of Lossy-Join Decomposition
Lossy-join decompositions result in information
loss.
Example: Decomposition of R = (A, B)
R
1
= (A) R
2
= (B)
A B
o
o
|
1
2
1
A
o
|
B
1
2
r
[
A
(r)
[
B(r)

[
A
(r) [
B
(r)
A B
o
o
|
|
1
2
1
2
Example
In our example:
course teacher
course book
The above formal definition is supposed to formalize
the notion that given a particular value of Y (course)
it has associated with it a set of values of Z (teacher)
and a set of values of W (book), and these two sets
are in some sense independent of each other.
Note:
If Y Z then Y Z
Indeed we have (in above notation) Z
1
= Z
2
The claim follows.
Fourth Normal Form
A relation schema R is in 4NF with respect
to a set D of functional and multivalued
dependencies if for all multivalued
dependencies in D
+
of the form o |,
where o _ R and | _ R, at least one of the
following hold:
o | is trivial (i.e., | _ o or o | = R)
o is a superkey for schema R
If a relation is in 4NF it is in BCNF
Lossy Decompositions
Not all decompositions are reversible (lossless)

Example:
Shipment(S#, P#, J#) decomposed into SP(S#, P#) and SJ(S#, J#)
s1 p1 j1 s1 p1 s1 j1
s2 p2 j1 s2 p2 s2 j1
s2 p3 j2 s2 p3 s2 j2
s3 p3 j3 s3 p3 s3 j3
s4 p4 j3 s4 p4 s4 j3

Lossy Decompositions
Shipment(S#, P#, J#) decomposed into SP(S#, P#) and SJ(P#, J#)
s1 p1 j1 s1 p1 p1 j1
s2 p2 j1 s2 p2 p2 j1
s2 p3 j2 s2 p3 p3 j2
s3 p3 j3 s3 p3 p3 j3
s4 p4 j3 s4 p4 p4 j3
If we join SP and SJ again into SP-PJ(S#, P#, P#, J#) we get:
s1 p1 p1 j1
s2 p2 p2 j1
s2 p3 p3 j2 from the joined tuples we cannot
s2 p3 p3 j3 deduce the original form of the data.
s3 p3 p3 j2 this is called the connection trap
s3 p3 p3 j3 and the decomposition is lossy
s4 p4 p4 j3
Fourth Normal Form (4NF)
Multi-valued dependency (MVD)
represents a dependency between attributes (for example, A,
B and C) in a relation, such that for each value of A there is a
set of values for B and a set of value for C. However, the set of
values for B and C are independent of each other.
A multi-valued dependency can be further defined as being
trivial or nontrivial. A MVD A > B in relation R is defined
as being trivial if
B is a subset of A
or
A U B = R
A MVD is defined as being nontrivial if neither of the above two
conditions is satisfied.
Fourth Normal Form (4NF)
Fourth normal form (4NF)
A relation that is in Boyce-Codd normal form and contains
no nontrivial multi-valued dependencies.
Fifth Normal Form (5NF)
Lossless-join dependency
A property of decomposition, which ensures that no spurious
tuples are generated when relations are reunited through a
natural join operation.

Join dependency
Describes a type of dependency. For example, for a relation
R with subsets of the attributes of R denoted as A, B, , Z, a
relation R satisfies a join dependency if, and only if, every
legal value of R is equal to the join of its projections on A, B,
, Z.
Fifth normal form (5NF)
A relation that has no join dependency.
Unnormalised
(UDF)
First normal form
(1NF)
Remove repeating groups
Second normal form
(2NF)
Remove partial dependencies
Third normal form
(3NF)
Remove transitive dependencies
Boyce-Codd normal
form (BCNF)
Remove remaining functional
dependency anomalies
Fourth normal form
(4NF)
Remove multivalued dependencies
Fifth normal form
(5NF)
Remove remaining anomalies
Stages of Normalisation
R =(A, B, C, D).
F = {CD, CA, BC}.

Question 1: Identify all candidate keys for R.

Question 2: Identify the best normal form that R
satisfies.

Question 3: Decompose R into a set of BCNF
relations.

Question 4: Decompose R into a set of 3NF
relations.
Assignment 2 Exercise

You might also like