This document provides examples and explanations of database normalization. It discusses the first, second, and third normal forms (1NF, 2NF, 3NF), and uses a customer complaint tracking database as an example to demonstrate the normalization process. The example database is initially defined in 1NF format, then transformed through 2NF and 3NF, with anomalies identified and addressed at each step. Additional requirements are added, prompting further updates to the normalized database relations.
2. Recap
Normal Forms
● 1NF
● No repeating groups
● Primary Keys
● 2NF
● 1NF requirements met
● No partial dependencies
● 3NF
● 2NF requirements met
● No transitive dependencies
● None of the above guarantees the removal of all
anomalies
3. The pen is mightier than…
● … a boring lecture
● For this presentation you are going to need
4. Example 1
Complaints
● A company needs a database to handle complaints
that are lodged with their customer services
department
● Customers lodge complaints against a particular
department, on a particular date for a particular
reason
● Each department has a name, location, telephone
extension and a manager
● Each manager has a name
● Each customer has a name
5. Example 1 cont.
Complaints
● Each department has only ONE manager
● A department can have multiple complaints
lodge against it
● A customer can lodge one complaint per
department
● Managers, departments and customers all
have id numbers of some sort
7. Example 1 cont.
Complaints
● Write the relation in 1NF
Complaints (DeptNum, CustNum,
CustName, Date, Description,
DeptName, Location, MngrName,
MngrID, TelExtn)
8. Example 1 cont.
Complaints
● Write down all anomalies that could occur
giving an example of each
● Insert
● Can’t add a department without a complaint against it
● Update
● Updating a customer or manager name requires
updates in one or more places
● Deletion
● Deleting all complaints against a department deletes
the entire department
9. Example 1 cont.
Complaints
● Identify the partial and transitive
dependencies
● CustName partially dependent on CustNum
● DeptName, Location, TelExtn and MngrID
partially dependent on DeptNum
● MngrName transitively dependent on MngrID
● Only the Date and Description are functionally
dependent on the entire key
10. Example 1 cont.
Complaints
● Write the relation(s) in 2NF
Complaints (DeptNum, CustNum, Date,
Description)
Departments(DeptNum, DeptName,
Location, MngrName, MngrID,
TelExtn)
Customers(CustNum, CustName)
11. Example 1 cont.
Complaints
● Write down all anomalies that could occur
giving an example of each
● Update
● Changing the manager of a department requires a
change of both the manager’s ID and name
12. Example 1 cont.
Complaints
● Write the relations in 3NF
Complaints (DeptNum, CustNum, Date,
Description)
Departments (DeptNum, DeptName,
Location, MngrID, TelExtn)
Managers (MngrID, MngrName)
Customers (CustNum, CustName)
13. Example 1 cont.
Complaints
● Let’s assume that the company wants to add
contact details for the customers who
complain
● They want to be able to store more than one
contact number per customer
● In addition customers must be able to lodge
multiple complaints against a department
● Make the appropriate changes to the
relations