Professional Documents
Culture Documents
Part 1
What is Data Normalization?
•The process of decomposing relations
with anomalies to produce smaller,
well-structured relations
Importance of Normalization
•To reduce anomalies
▫ Database that is free of update, insertion
and deletion anomalies
Anomalies
Types of Anomaly
• An anomaly is an inconsistent, incomplete, or
contradictory state of the database
• An undesirable side effect
• Types of anomalies
▫ Insertion anomaly
▫ Deletion anomaly
▫ Update anomaly
Insertion Anomaly
• Inserting a partial record (prime attribute is unknown at the time of insertion)
▫ Problem with composite PKs
• user is unable to insert a new record of data when it should be possible to do so because not all
other information is available.
▫ A new course has been approved CUIT220 called Oracle Programming is it possible to enter this course ?
▫ New department no course yet?
COURSE-CONTENT(Course, Content)
Maromba Harare
CNC hardware
Plant Manager Machine Supplier-Name Supplier-City
FDs
• Plant Manager
• Supplier-Name SupplierCity
Plant(Plant, Manager, Machine, Supplier-Name, Supplier-City)
COURSE-REGISTRATION:
(Student Name,
Registration Number,
Programme, Level, {
CourseNumber,
CourseName })
Student_Course Table (1NF)
LastName FirstName RegNumber Programme Level Course_Num Course_Name
FDs
• RegNumberLastName, FirstName, Programme, Level
• Course_NumCourse_Name
Update anomalies of the Student-Course table
▫ Insertion anomaly
New student not yet registered any course
New course no students assigned to it
▫ Deletion anomaly
Only one student registered for a certain course and
decides to drop that course?
▫ Update anomaly
Multiple occurrences of LastName
Transform the Order Form to 1NF
Normalization
2nd Normal Form
Second Normal Form
• A table is in 2NF if it is in 1NF and has no partial dependencies.
▫ Prime/key attribute − An attribute, which is a part of the prime-
key, is known as a prime attribute.
▫ Non-prime/key attribute − An attribute, which is not a part of the
prime-key, is said to be a non-prime attribute.
• Every non-key attribute should be fully functionally dependent on
the primary key.
Resolving Partial Dependency
• Make new relations to Eliminate Partial
Dependencies
▫ For each component of the primary key that acts as a
determinant in a partial dependency, create a new table
with a copy of that component as the primary key.
• Decompositions must be loss less
▫ One of the relations must contain a super key
Decompose R into 2NF
R(A,B,C,D); F={AC, ABD}
• R is not in 2NF because C is not fully
dependent on the primary key (partial
dependency)
• AC : R1(A, C) and
• ABD : R2(A,B, D)
SK in R2
Normalise COURSE-CONTENT to 2NF
FDs F ={Content Course}
COURSE-CONTENT(Course, Content)
• The key is single attribute key
• Non key attribute Course is fully dependent
on PK Content
• The relation is already in 2NF
Plant Manager Machine Supplier-Name Supplier-City
FDs
• OrderNumCustNum, CustName, CustAddress, City, Country, Date
• CustNum CustName, CustAddress, City, Country
• ProductNo Des, UnitPrice
• OrderNum, ProductNoQTY