Normalization For Relational Databases
Normalization For Relational Databases
Person
P_Id LastName FirstName City
1 Hasnen Khalid Karachi
2 Ahmed Sania Sukkur
3 Raza Haroon Jamshoro
Orders
O_Id OrderNo P_Id
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Slide 3- 5
Primary and Foreign Keys
P Person
r P_Id LastName FirstName City
i 1 Hasnen Khalid Karachi
m
a 2 Ahmed Sania Sukkur
r 3 Raza Haroon Jamshoro
y
k Orders
e O_Id OrderNo P_Id
y 1 77895 3
s 2 44678 3
3 22456 2
4 24562 1
Slide 3- 6
Primary and Foreign Keys
P Person
r P_Id LastName FirstName City
i 1 Hasnen Khalid Karachi
m
a 2 Ahmed Sania Sukkur
r 3 Raza Haroon Jamshoro
y
k Orders
e O_Id OrderNo P_Id
y 1 77895 3
s 2 44678 3
Foreign keys
3 22456 2
4 24562 1
Slide 3- 7
Primary and
Foreign Keys
Company Database
Slide 3- 8
Primary and Foreign Keys
Slide 3- 9
Primary and Foreign Keys
Slide 3- 10
Concatenated (Composite) Primary Key
1 1 17 47.8700 50.2635
2 104 19 39.9200 41.9160
7 4 17 54.3100 57.0255
609 1 17 25.7700 27.0585
609 100 19 28.1700 29.5785
ProductVendor
Slide 3- 11
Concatenated (Composite) Primary Key
Primary key
1 1 17 47.8700 50.2635
2 104 19 39.9200 41.9160
7 4 17 54.3100 57.0255
609 1 17 25.7700 27.0585
609 100 19 28.1700 29.5785
ProductVendor
Slide 3- 12
Normalization
Normalization is the process of eliminating various
anomalies (or undesirable aspects) of a relation in
order to obtain “better” relations.
A relation is said to be in normal form if following
problems are eliminated:
1) Repetition anomaly
2) Update anomaly
3) Insertion anomaly
4) Deletion anomaly
Slide 3- 13
Normalization: Repetition Anomaly
Certain information may be repeated unnecessarily.
Consider, for example, the EMP relation. The
name, title, and salary of an employee are repeated
for each project on which this person serves. This
is obviously a waste of storage and is contrary to
the spirit of databases.
Slide 3- 14
Slide 3- 15
Normalization: Update Anomaly
As a consequence of the repetition of data,
performing updates may be troublesome. For
example, if the salary of an employee changes,
multiple tuples have to be updated to reflect this
change.
Slide 3- 16
Slide 3- 17
Normalization: Insertion Anomaly
It may not be possible to add new information to the
database. For example, when a new employee
joins the company, we cannot add personal
information (name, title, salary) to the EMP relation
unless an appointment to a project is made. This is
because the key of EMP includes the attribute
PNO, and null values cannot be part of the key.
Slide 3- 18
Slide 3- 19
Normalization: Deletion Anomaly
This is the converse of the insertion anomaly. If an
employee works on only one project, and that
project is terminated, it is not possible to delete the
project information from the EMP relation. To do so
would result in deleting the only tuple about the
employee, thereby resulting in the loss of personal
information we might want to retain.
Slide 3- 20
Slide 3- 21
Normalization
A relation with one or
more of the above
mentioned anomalies is
split into two or more
relations of a higher
normal form.
Slide 3- 22
Normalization
A relation with one or
more of the above
mentioned anomalies is
split into two or more
relations of a higher
normal form.
E. F. Codd initially
defined the first,
second, and third
normal forms (1NF,
2NF, and 3NF,
respectively).
Slide 3- 23
Un-normalized Relation
Slide 3- 24
Relations in Normalized Form
Slide 3- 25
Slide 3- 26
Slide 3- 27
Slide 3- 28
item color price tax
Slide 3- 29
Slide 3- 30
Exercise – 1NF
Slide 3- 31
Exercise – 1NF
Slide 3- 32
Slide 3- 33
Slide 3- 34
Slide 3- 35
Exercise – 2NF
Slide 3- 36
Exercise – 2NF
Slide 3- 37
Slide 3- 38
Slide 3- 39
Slide 3- 40
Slide 3- 41
Slide 3- 42
Bring Following Table in 1ST and 2ND Normal Form
Slide 3- 43
Assignment
Slide 3- 44
Assignment
Slide 3- 45
Slide 3- 46
Slide 3- 47