The Normal Forms 3NF and BCNF
The Normal Forms 3NF and BCNF
A relation R is in 2NF if
– (a) R is 1NF , and
– (b) all non-prime attributes are fully dependent
on the candidate keys. Which is creating
relationships between these new tables and
their predecessors through the use of foreign
keys.
A prime attribute appears in a candidate key.
There is no partial dependency in 2NF.
Example is next…
No dependencies on non-key attributes
Inventory
There are two non-key fields. So, here are the questions:
•If I know just Description, can I find out Cost? No, because
we have more than one supplier for the same product.
•If I know just Supplier, and I find out Cost? No, because I
need to know what the Item is as well.
Inventory
Description Supplier Cost
CONTINUED…
Inventory
Description Supplier Cost Supplier Address
•If I know just Description, can I find out Supplier Address? No,
because we have more than one supplier for the same product.
•If I know just Supplier, and I find out Supplier Address? Yes.
The Address does not depend upon the description of the item.
Supplier
Name Supplier Address
So putting things together
Inventory
Description Supplier Cost Supplier Address
Inventory
Description Supplier Cost
Supplier
Name Supplier Address
The above relation is now in 2NF since the relation has no non-
key attributes.
3) Remove columns that are not
dependent upon the primary key.
So for every nontrivial functional dependency X --> A,
(1) X is a superkey, or
(2) A is a prime (key) attribute.
Example of 3NF
Books
Author's Non-de
Name Author's Name # of Pages
Plume
•If I know # of Pages, can I find out Author's Name? No. Can I find out
Author's Non-de Plume? No.
•If I know Author's Name, can I find out # of Pages? No. Can I find out
Author's Non-de Plume? YES.
Books
Author
Name Non-de Plume
Another example: Suppose we have relation S
S(SUPP#, PART#, SNAME, QUANTITY) with the following assumptions:
S1 P1
Yues
100
S1 Yues P2 200
S2 Yues P3 250
S2 Jones P1 300
Example with first three forms
Suppose we have this Invoice Table
For example, two tuples have to be updated if the roomNo need be changed for
staffNo SG5 on the 13-May-02.
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 StaffRoom as shown below,
StaffRoom
staffNo interviewDate roomNo
SG5 13-May-02 G101
SG37 13-May-02 G102
SG5 1-Jul-02 G102