2. Proposed By E.F. Codd
Normalization
tool to validate and improve logical design
Process of decomposing relation with anomalies and
produces smaller, well structured relation.
What is it?
Normalisation by Ms.Amrit Kaur 2
3. Organize the attributes (columns) and tables
(relation) of relational database to
reduce Data redundancy
improve Data Integrity
No data inconsistency
Decide which attributes should be group together
in a table to create an accurate representation of
data, its relationship and constraint
Objective
Normalisation by Ms.Amrit Kaur 3
5. Normalization is executed as series of steps. Each
step correspond to specific normal form.
Normal form is a state of relation(table) generated
by applying rules regarding relationship between
attributes to that relation.
Process
Normalisation by Ms.Amrit Kaur 5
7. First step of Normalization
First normal form
Normalisation by Ms.Amrit Kaur 7
8. First Normal Form
RULE: A relation is said to be in First Normal Form if each
cell contains one and only one value.
Converting Unnormalized relation to 1 NF
Enter data into empty columns of rows
Create separate row for multivalued column
1NF
Normalisation by Ms.Amrit Kaur 8
9. CustNo CustName ProdNo ProdName Price Qty OrderDate
????
C101
John P001 Pen 10 100 10.Oct.2020
John P002 Pencil 3 200 11.Oct.2020
????
????
C102
Pat P001 Pen 10 130 10.Oct.2020
Pat P1004 Eraser 5 150 12.Oct.2020
Pat P006 Ruler 7 200 11.Oct.2020
Unnormalised Table
Normalisation by Ms.Amrit Kaur 9
CustNo CustName ProdNo ProdName Price Qty OrderDate
C101
C101
John
?????
P001
P002
Pen
Pencil
10
3
100
200
10.Oct.2020
????
C102
Pat P001 Pen 10 130 10.Oct.2020
Pat P1004 Eraser 5 150 12.Oct.2020
Pat P006 Ruler 7 200 11.Oct.2020
10. CustNo CustName ProdNo ProdName Price Qty OrderDate
C101 John P001 Pen 10 100 10.Oct.2020
C101 John P002 Pencil 3 20
0
11.Oct.2020
C102 Pat P001 Pen 10 130 10.Oct.2020
C102 Pat P1004 Eraser 5 150 12.Oct.2020
C102 Pat P006 Ruler 7 200 11.Oct.2020
Table in 1NF
Normalisation by Ms.Amrit Kaur 10
12. Second Normal Form
RULE: A relation is in 2NF if and only if it is in 1NF and
every non key attributes are FULLY functionally
dependent on primary key.
Procedure: Converting from 1NF to 2NF
Identify functional dependencies
Identify primary key
Identify partial dependencies on primary key,
If partial dependencies exist, remove it from 1NF relation by
placing them in new relation along with copy of determinant.
2NF
Normalisation by Ms.Amrit Kaur 12
14. Functional Dependencies defines relation between
attributes(columns) in a relation(table).
Given a relation R, a set of attributes X in R is said
to be functionally dependent on another set of
attribute Y if and only if, for each one X value in R is
associated with precisely one Y value in R.
What is it?
Normalisation by Ms.Amrit Kaur 14
15. Y(attribute) functionally dependent on X(attribute)
It is denoted by X->Y
The attribute on left hand side of arrow is called
determinant.
The attribute on right side of arrow is called dependent.
How is it represented?
Normalisation by Ms.Amrit Kaur 15
16. Partial Functional Dependencies
A functional dependency in which one or more non key
attributes are functionally dependent on part of primary key.
Fully Functional Dependencies
A functional dependency in which one or more non key
attributes are totally depending functionally dependent on
primary key.
Transitivity Dependencies
Types of Functional Dependencies
Normalisation by Ms.Amrit Kaur 16
18. CourseNo DepartmentName CourseName Room Enrollment
4604 CS Database 201 45
4604 Dance Tree Dancing 302 45
4604 English The Basics of Data 123 45
2604 CS Data Structure 456 100
2604 Physics Dark Matter 302 100
Step 1 ….Identify FD
Normalisation by Ms.Amrit Kaur 18
Relation (Functional Dependency between CourseNo(X) and DepartmentName(Y)
For each X values(CourseNo) 4604 – How many departmentName ???? … 3 (CS,Dance,
English)….all are different…. 3 Y values (DepartmentName) .
Hence, CourseNo and DepartmentName not functionally dependent
Relation (Functional Dependency between CourseNo(X) and CourseName(Y)
For each X values(CourseNo) 4604 – How many courseName ?? … 3 different
courseName. It means 3 Y values (DepartmentName) .
Hence, CourseNo and CourseName not functionally dependent
19. CourseNo DepartmentName CourseName Room Enrollment
4604 CS Database 201 45
4604 Dance Tree Dancing 302 45
4604 English The Basics of Data 123 45
2604 CS Data Structure 456 100
2604 Physics Dark Matter 302 100
[contd.] Step 1
Normalisation by Ms.Amrit Kaur 19
Relation (Functional Dependency between CourseNo(X) and Room(Y)
For each X values(CourseNo) 4604 –3 different rooms; i.e. 3 Y values .
Hence, CourseNo and Room not functionally dependent
Relation (Functional Dependency between CourseNo(X) and EnrollmentY)
For each X values(CourseNo) 4604 – How many enrollment?? … 3 but value is 1; i.e.
45. It means 1 Y Value
Hence, CourseNo and Enrollment are functionally dependent. CourseNo ->Enrollment
20. Identified Functional Dependencies considering each
attributes individually and then attribute combinations
1. CourseNo -> Enrollment
2. CourseName -> Room
3. CourseName->Enrollment
4. CourseNo+DepartmentName -> CourseName
5. CoursrNo+DepartmentName -> Room
6. CourseNo+ Department -> Enrollment
7. CourseName+DepartmentName -> CourseNo
8. CoursrName+DepartmentName -> Room
9. CourseName+ Department -> Enrollment
[contd] Step 1
Normalisation by Ms.Amrit Kaur 20
21. Make list of Determinants from identified FDs
Rules of Choosing Primary Key
Dependent cannot be primary key
For Determinant, the column must not contain duplicate
values
Step 2 ….Choose Primary Key
Normalisation by Ms.Amrit Kaur 21
22. List of Determinants
(left hand side of FDs)
CourseNo
CourseName
CourseNo+DepartmentName
CourseName+ DepartmentName
Identified functional dependencies in Step 1
[contd.] Step 2
Normalisation by Ms.Amrit Kaur 22
• Apply Rules
– In FD (4), CourseName is dependent
– In FD (7), CourseNo is dependent
Both Cannot be Primary Key
1. CourseNo -> Enrollment 2. CourseName -> Room
3. CourseName->Enrollment 4. CourseNo+DepartmentName -> CourseName
5.CoursrNo+DepartmentName -> Room 6.CourseNo+ Department -> Enrollment
7.CourseName+DepartmentName -> CourseNo 8. CoursrName+DepartmentName -> Room
9. CourseName+ Department -> Enrollment
• Choose any ONE as Primary Key
– CourseNo + DepartmentName
– CourseName + DepartmentName
23. Partial Dependency means
one or more non key
attributes are functionally
dependent on part of primary
key.
Identified functional dependencies in Step 1
Step 3…. Identify Partial Dependencies
Normalisation by Ms.Amrit Kaur 23
DepartmentName->Enrollment (FALSE)
It means from FD(1), Enrollment is depending
on primary key as a whole and also ONLY on
CourseNo (part of primary Key) .
1. CourseNo -> Enrollment 2. CourseName -> Room
3. CourseName->Enrollment 4. CourseNo+DepartmentName -> CourseName
5.CoursrNo+DepartmentName -> Room 6.CourseNo+ Department -> Enrollment
7.CourseName+DepartmentName -> CourseNo 8. CoursrName+DepartmentName -> Room
9. CourseName+ Department -> Enrollment
• Identified PRIMARY KEY in Step2 CourseNo + DepartmentName
• Partial Dependencies Exist
CourseNo - Enrollment
24. Remove partial dependencies Enrollment from Table in 1 NF
Create separate table with Enrollment
Copy determinants CourseNo also
Step 4 ….Remove Partial
Dependencies
Normalisation by Ms.Amrit Kaur 24
Course
No
DepartmentName CourseName Room
4604 CS Database 201
4604 Dance Tree Dancing 302
4604 English The Basics of Data 123
2604 CS Data Structure 456
2604 Physics Dark Matter 302
CourseNo Enrollment
4604 45
2604 100
After 2NF, Table Structure
25. CustNo CustName ProdNo ProdName Price Qty Order
No
OrderDate
C101 John P001 Pen 10 100 1 10.Oct.2020
C101 John P002 Pencil 3 200 2 11.Oct.2020
C102 Pat P001 Pen 10 130 3 10.Oct.2020
C102 Pat P1004 Eraser 5 150 4 12.Oct.2020
C102 Pat P006 Ruler 7 200 5 11.Oct.2020
Example 2. Convert Table to 2NF
Normalisation by Ms.Amrit Kaur 25
Step1: Identify Functional Dependency
(CustNo+ProdNo)->Qty
(CustNo+ProdNo)->ProdName
(CustNo+ProdNo)-> Price
(CustNo+ProdNo)->OrderNo
(CustNo+ProdNo)->OrderDate
Step2: Identify Primary Key
(CustNo+ProdNo)
Step3: Partial Dependency
(CustomerName is depending only on CustNo,
not on ProdNo
CustNo->Custname
(ProductName is depending only on ProdNo
not on CustNo
Prodno->ProdName
STEP 4. Remove dependencies CustName and ProdName from Table in 1 NF and create
two separate tables and copy determinants CustNo and ProdNo respectively.
28. Third Normal Form
RULE: A relation is in 3NF if and only if it is in
2NF and every nonkey attribute is non
transitively dependent on primary key.
Procedure: Converting 2NF to 3NF
Identify Functional Dependencies
Identify primary key
If transitive dependency exist on primary key, remove them
by placing them in new relation along with dominant.
3NF
Normalisation by Ms.Amrit Kaur 28
29. A transitive dependency exists when the following
functional dependency pattern:
A → B
B → C ; therefore A → C.
If any attribute is depending upon primary key and also
depending upon other attribute
What is Transitive Dependency?
Normalisation by Ms.Amrit Kaur 29
35. Relations in 3NF still contain redundancy when
There are two or more candidate key
Candidate Keys are composite key
Candidate Key overlaps (one attribute common)
BCNF
RULE: A relation is in BCNF if and only if every
determinant is a candidate key
BCNF
Normalisation by Ms.Amrit Kaur 35
36. Procedure: Converting to BCNF
Identify all candidate keys
Indentify all functional dependencies
If functional dependencies exist where determinants are
not candidate key, remove functional dependencies by
placing them in new relation along with determinant
BCNF
Normalisation by Ms.Amrit Kaur 36
37. Example: Apply BCNF
Normalisation by Ms.Amrit Kaur 37
ClientNo InterviewDate Interview Time Staff No Room No
C176 20-Oct-2020 10:30 S5 101
C156 20-Oct-2020 12:00 S5 101
C174 20-Oct-2020 12:00 S37 102
C156 22-Oct-2020 10:30 S5 102
Primary Key (ClientNo,InterviewDate)->(InterviewTime,StaffNo,RoomNo)
Candidate Keys
1. (StaffNo,InterviewDat,InterviewTime) -> (ClientNo, RoomNo)
2. (RoomNo,InterviewDate,InterviewTime)-> (StaffNo, ClientNo)
Other Functional Dependency – Determinant not Candidate Key
Remove and create another relation and copy determinant
1. (StaffNo, InterviewDate) -> RoomNo
38. After BCNF
Normalisation by Ms.Amrit Kaur 38
ClientNo InterviewDate Interview Time Staff No
C176 20-Oct-2020 10:30 S5
C156 20-Oct-2020 12:00 S5
C174 20-Oct-2020 12:00 S37
C156 22-Oct-2020 10:30 S5
Staff No InterviewDate Room No
S5 20-Oct-2020 101
S37 20-Oct-2020 101
S5 22-Oct-2020 102