Normalization
Normalization
Week 3
National College of Ireland
Dublin, Ireland.
(a) CUSTOMER
entity type with
simple attributes
4
Purpose of Normalization
• When we design a database, the main objective is to create an
accurate representation of the data, relationships between the
data, and constraints.
Developed by E.F. Codd (1972).
9
Data Redundancy and Update
Anomalies
• StaffBranch relation has redundant data; the details of a branch are
repeated for every member of a staff.
• In contrast, the branch information appears only once for each branch in the
Branch relation and only the branch number (branchNo) is repeated in the
Staff relation, to represent where each member of staff is located.
• Relations that contain redundant information may potentially
suffer from update anomalies.
StaffBranch
StaffBranch
StaffBranch
• For example, if we delete the tuple for staff number SA9 (Mary Howe)
from the StaffBranch relation, the details relating to branch number
B007 are lost from the database. 13
Modification Anomalies
StaffBranch
• If we want to change
the value of one of the
attributes of a
particular branch in
the StaffBranch
relation.
• For example, the address for branch number B003, we must update the tuples
of all staff located at that branch.
• If this modification is not carried out on all the appropriate tuples of the
StaffBranch relation, the database will become inconsistent.
Staff Branch
The design of the relations in the above Figure avoids this problem,
because the branch tuples are stored separately from staff tuples and
only the attribute branchNo relates the two relations.
If we delete the tuple for staff number SA9 from the Staff relation, the
details on branch number B007 remain unaffected in the Branch
relation. 15
Functional Dependency
Describes the relationship between
attributes in a relation. For example, if A
and B are attributes of a relation R.
• On the other hand, the relationship between sName and staffNo is one-
to-many (1:*): there can be several staff numbers associated with a
given name.
• However, the only functional dependency that remains true for all
possible values for the staffNo and sName attributes of the Staff relation
is: staffNo → sName 17
Full Functional Dependency
22
Unnormalized Form (UNF)
• A collection of (simplified)
DreamHome leases is shown
in Figure 13.9.
Unnormalized
table with rows
• The lease on top is and columns
for a client called
John Kay who is
leasing a property
in Glasgow, which
is owned by Tina
24
Murphy.
UNF to 1NF
• Next, we identify the repeating group in the unnormalized table as the
property rented details, which repeats for each client.
• For example, there are two values for propertyNo (PG4 and PG16) for the
client named John Kay.
1NF
• A relation in which
the intersection of
each row and
column contains one
and only one value.
26
UNF to 1NF
Key
attribute
is the
client
number
Partial dependency
Partial dependency
Transitive dependency
27
Second Normal Form (2NF)
ClientRental
Rental
Transitive dependency
30
Second Normal Form (2NF)
35
Third Normal Form (3NF)
This figure illustrates the process by which the original 1NF relation is
decomposed into the 2NF and 3NF relations.
The resulting 3NF relations have the form:
▪ Client (clientNo, cName)
▪ Rental (clientNo, propertyNo, rentStart, rentFinish)
▪ PropertyForRent (propertyNo, pAddress, rent, ownerNo)
▪ Owner (ownerNo, oName) 39
Third Normal Form (3NF)