DB Design Normalization
DB Design Normalization
(Fall 2022)
Database Design-Normalization
Asst.Prof.Dr. Hasan ÇİFCİ
Agenda
▪ Refresh: Keys
▪ Normalization
▪ Data Redundancy
▪ Anomalies
▪ Functional Dependencies (FD)
▪ The Process of Normalization
▪ Examples
2/62
Refresh: Keys
3/62
Refresh: Keys
6/62
Benefit of Normalization
7/62
How Normalization Supports Database
Design
• 2 approaches for using normalization:
• Approach 1 – normalization can be used as a bottom-up
standalone database design technique.
• Approach 2 – normalization can be used as a validation technique
to check the structure of relations, using a top-down approach
such as ER modeling.
• Goal – creating a set of well-designed relations that meet the data
requirements of the enterprise.
8/62
Data Redundancy
9/62
Data Redundancy
10/62
Data Redundancy
Situation 1 VS Situation 2
Information of staffs in Staff relation
Both information of staffs and branch
Information of branch in Branch
are in StaffBranch relation
relation
11/62
Update Anomalies
Figure 1
Unwanted data
redundancy may cause
update anomalies
12/62
Insertion Anomalies
14/62
Deletion Anomalies
16/62
Functional Dependencies (FD)
17/62
FD: Determinant
determinant
18/62
Example of a Functional Dependency
19/62
Functional Dependencies
20/62
Functional Dependencies
21/62
Functional Dependencies
22/62
Full Functional Dependency
23/62
Transitive Dependency
24/62
Identifying Functional Dependencies
25/62
Identifying Functional Dependencies
The sample relation
displaying data for
attributes A,B,C,D
and E and the
functional
dependencies (fd1 to
fd4) that exist
between these
attributes.
A → C (fd1)
C → A (fd2)
B → D (fd3)
A,B → E (fd4)
B,C → E (fd5)
26/62
Identifying Functional Dependency
27/62
The Process of Normalization
28/62
The Process of Normalization
29/62
sources
The Process of Normalization
Data
30/62
First Normal Form (1NF)
31/62
UNF: Example
Collection of
DreamHome leases
Repeating Groups
ClientRental
Unnormalized table
32/62
1NF Example: 1st Approach
33/62
1NF Example: 2nd Approach
35/62
First Normal Form (1NF)
Important
▪ If you are using normalization as a validation technique to validate
relations that are derived from conceptual ER model, we can safely
say that the derived relations are already in 1NF, where the
assumption is a row of record in the relation is considered as one
complete tuple.
36/62
Second Normal Form (2NF)
37/62
1NF to 2NF: What to do?
38/62
2NF Example
• Let us use the 1NF ClientRental relation (obtained from the 1st
approach).
• list its FDs
• determine the PK for ClientRental
39/62
2NF Example
40/62
2NF Example
→ PK is clientNo, propertyNo
→ Subsets of PK:
→{clientNo}, {propertyNo}, {clientNo, propertyNo}
→ determinant in FD2 and FD3 is subset of PK
FDs list in ClientRental
FD1 : clientNo, propertyNo → rentStart, rentFinish
FD2 : clientNo → cName (partial dependency)
FD3 : propertyNo → pAddress, rent, ownerNo, oName (partial dependency)
FD4 : ownerNo → oName
FD5 : clientNo, rentStart → propertyNo, pAddress, rentFinish, rent, ownerNo, oName
FD6 : propertyNo, rentStart → clientNo, cName, rentFinish
41/62
2NF Example
2NF Relations:
From FD2: Client (clientNo, clientName)
From FD3: PropertyOwner (propertyNo, pAddress, ownerNo, oName)
The rest : Rental (clientNo, propertyNo, rentStart, rentFinish)
These are our latest set of relations. All of them are now in 2NF
as every non-PK attribute is fully FD on the PK of the relation.
42/62
2NF Example
43/62
Third Normal Form (3NF)
44/62
2NF to 3NF: What to do?
45/62
3NF: Example
2NF relations:
Client (clientNo, clientName)
i. FD2 : clientNo → cName
47/62
3NF: Example
PropertyOwner
(2NF)
PropertyForRent (3NF)
Owner (3NF)
48/62
3NF: Example
• These are our final set of normalized relations in the 3NF derived from
the ClientRental relation.
• Client (clientNo, cName)
• Rental (clientNo, propertyNo, rentstart, rentFinish)
• PropertyForRent (propertyNo, pAddress, rent, ownerNo)
• Owner (ownerNo, oName)
49/62
Boyce-Codd Normal Form (BCNF)
50/62
Boyce-Codd Normal Form (BCNF)
51/62
BCNF: Example
Non-candidate key determinant This relation is in 1NF, 2NF, 3NF, BUT NOT
BCNF, because fd4 determinant is not a CK
52/62
BCNF: Example
53/62
Example of DreamHome
54/62
Another Example
55/62
Another Example
• UNF to 1NF:
• StaffPropertylnspection (propertyNo, iDate, iTime, pAddress,
comments, staffNo, sName, carReg)
56/62
Another Example
• Dependency
57/62
Another Example
1NF:
StaffPropertylnspection (propertyNo, iDate, iTime, pAddress, comments, staffNo, sName, carReg)
2NF:
Propertylnspection (propertyNo, iDate, iTime, comments, staffNo, sName, carReg)
Property (propertyNo, pAddress)
Transitive dependency
58/62
Another Example
3NF:
Propertylnspection (propertyNo, iDate, iTime, comments, staffNo, carReg)
Staff (staffNo, sName)
Property (propertyNo, pAddress)
BCNF:
lnspection (propertyNo, iDate, iTime, comments, staffNo, carReg)
StaffCar (staffNo, iDate, carReg)
Staff (staffNo, sName)
Property (propertyNo, pAddress)
59/62
Another Example
60/62
Summary
61/62
Thank you…
Hasan ÇİFCİ