1. Normal forms & Normalization
Proposed by Edgar F. Codd
Integral part of Relational Databases
Reduce redundancy & improve data
integrity
Top down refinement process
Relational design by analysis
3. Definition :
Normalization is the process of analyzing relation schemas
based on their Functional Dependencies and Primary
Keys to achieve the desirable properties of :
Minimizing redundancy
Minimizing insertion, deletion & updation
anomalies.
Normal Form of a relation refers to the degree to which it
has been normalized.
5. First Normal form
Only Atomic Values
Disallow Multi-valued & Composite
Attributes
DEPARTMENT
DNAME DNUMBER MANAGER_ID DLOCATIONS
DNAME DNUMBER MANAGER_ID DNUMBER DLOCATIONS
6. Second normal form
• Full Functional Dependency
• A relation schema is in 2 NF if it is in 1 NF and if every
non-prime attribute is fully functionally dependent on the
Primary key.
SSN PNUMBER HOURS ENAME PNAME PLOCATION
{ SSN, PNUMBER } HOURS ……….. Full Functional Dependency
{ ENAME, PNAME, PLOCATION } all are partially dependent on the key.
Hence the above relation is not in 2 NF
8. DEFINITION :
A relation schema is in 2 NF if it is in 1 NF and every non-
prime attribute is fully functionally dependent on the key.
A relation schema is in 2 NF if it is in 1 NF and every non-
prime attribute is not partially dependent on the key.
9. Third normal form
Transitive Dependency
In a relation schema R if there exist attributes X,Y,Z such
that :
X Y & Y Z, where Y is non-prime
Then, X Y is a transitive dependency through non-
prime attribute Y.
10. DEFINITION :
A relation schema is in 3 NF if
• it satisfies 2 NF and
• no non-prime attribute is transitively
dependent on the key.
12. Examples for practice
PROJ_ID PNAME PMGR_ID E_ID ENAME E_DEPT E_HRLY_RATE HOURS
PROJECT_EMPLOYEE
PROJ_ID PNAME PMGR_ID
PROJ_ID E_ID ENAME E_DEPT E_HRLY_RATE HOURS
PROJECT
PROJECT_EMPLOYEE
Now the relations are in 1NF.
{ ENAME, E_DEPT, E_HRLY_RATE } are partially dependent on the key { PROJ_ID, E_ID }
Therefore the relation is not in 2 NF
13. PROJ_ID PNAME PMGR_ID
PROJECT
E_ID ENAME E_DEPT E_HRLY_RATE
PROJ_ID E_ID HOURS
HOURS
Above relations are in 2 NF, but not in 3 NF.
E_ID E_DEPT, E_DEPT E_HRLY_RATE
So, E_ID E_HRLY_RATE is a transitive dependency.
E_ID ENAME E_DEPT E_DEPT E_HRLY_RATE
EMPLOYEE HOURLY_RATES
14. Q1) Consider the following relation :
CAR_SALE( CAR#, DATE_SOLD, SALESMAN#,
COMMISSION, DISCOUNT)
Additional functional dependencies are :
DATE_SOLD DISCOUNT
SALESMAN# COMMISSION
Based on the primary key, what is the highest normal form
of this relation. Normalize it to 3 NF.
15. Solution :
The relation is in 1NF.
It is not in 2 NF. As SALESMAN# COMMISSION
COMMISSION is partially dependent on the key { CAR#, SALESMAN#}
It is decomposed into two relations :
CAR_SALE(CAR#, DATE_SOLD, DISCOUNT, SALESMAN#)
SALES(SALESMAN#, COMMISSION)
These relations are in 2 NF but not in 3 NF.
CAR# DATE_SOLD, DATE_SOLD DISCOUNT
Further decomposition results :
CAR_SALE(CAR# , DATE_SOLD, SALESMAN#)
DATES(DATE_SOLD, DISCOUNT)
SALES(SALESMAN#, COMMISSION)
17. Q3) Schedule(stud_id, class_no, sname, course, class_time, room_no, instructor)
stud_id sname, course
Class_no class_time, room_no, instructor
Solution :
Relation is in 1 NF but not in 2 NF due to partial dependency on the key.
Therefore it is decomposed into :
STUDENT(STUD_ID, SNAME, COURSE)
CLASS(CLASS_NO, CLSS_TIME, ROOM_NO, INSTRUCTOR)
STUD_CLASS(STUD_ID, CLASS_NO)
18. Q4) Transaction(Trans_ID, item_no, price, qty_sold, seller, seller_discount)
Trans_id seller
Trans_id, item_no qty_sold
Item_no price
Seller seller_discount
Solution :
TRANSCATION(TRANS_ID, ITEM_NO, QTY_SOLD)
ITEMS(ITEM_NO, PRICE)
SELLER(TRANS_ID, SELLER, SELLER_DISCOUNT)
Above relations are in 2 NF but not in 3 NF. Further decomposition of SELLER leads to :
SELLER1(TRANS_ID, SELLER)
SELLER2(SELLER, SELLER_DISCOUNT)