Course Code: CS 261 Course Title: Database Management System Class Day: Wednesday Timing: 9 AM TO 12:00 PM Lecture / Week No. 07
Course Code: CS 261 Course Title: Database Management System Class Day: Wednesday Timing: 9 AM TO 12:00 PM Lecture / Week No. 07
1. Functional Dependencies
2. Normal Forms
• Normalization
• Solution: Normal Forms
• Introducing 3NF and BCNF
• 3NF
• Examples
Reference No. 1 Topic: Functional Dependencies
Functional Dependencies
Functional Dependencies
Reference No. 1 Topic: Functional Dependencies
Functional Dependencies
Reference No. 1 Topic: Normal Forms
Normalization
• Normalization is the process of efficiently
organizing data in a database with two goals in
mind
• First goal: eliminate redundant data
– for example, storing the same data in more than
one table
• Second Goal: ensure data dependencies make
sense
– for example, only storing related data in a table
Reference No. 1 Topic: Normal Forms
Benefits of Normalization
Table in 1NF
• 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…
Reference No. 1 Topic: Normal Forms
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
Reference No. 1 Topic: Normal Forms
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
Reference No. 1 Topic: Normal Forms
Inventory
Description Supplier Cost
Supplier
Name Supplier Address
•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
Name Author's Name # of Pages
Author
Name Non-de Plume
Reference No. 1 Topic: Normal Forms
Another example: Suppose we have relation S
• S(SUPP#, PART#, SNAME, QUANTITY) with the following
assumptions:
1. SUPP# is unique for every supplier.
2. SNAME is unique for every supplier.
3. QUANTITY is the accumulated quantities of a part supplied by a
supplier.
4. A supplier can supply more than one part.
5. A part can be supplied by more than one supplier.
We can find the following nontrivial functional dependencies:
(1) SUPP# --> SNAME
(2) SNAME --> SUPP#
(3) SUPP# PART# --> QUANTITY
(4) SNAME PART# --> QUANTITY
The candidate keys are:
(1) SUPP# PART#
(2) SNAME PART#
S1 P1
Yues
100
S1 Yues P2 200
S2 Yues P3 250
S2 Jones P1 300
Reference No. 1 Topic: Normal Forms
•Solution: you make a separate line item table, with it's own key, in this case the combination
of invoice
Reference No. 1 Topic: Normal Forms
key.
References / Resources