Normalization
Course Code: CSC 2108
Dept. of Computer Science
Faculty of Science and Technology
Lecturer No: 14 Week No: 09 Semester: TBA
Lecturer: Name & email
Course Title: Introduction to Database
Lecture Outline
1. Introduction
2. The Normal Forms
3. Modification Anomalies
4. Real World Exercise
Why Normalize?..
Why we need this
• Flexibility
Structure supports many ways to look at the data
• Data Integrity
“Modification Anomalies”
• Deletion
• Insertion
• Update
• Efficiency
Eliminate redundant data and save space
Normalization
Definition
Normalization
The process of decomposing relations with Anomalies to produce smaller Well-
Structure relations.
Normal Form
A relation that results from applying simple rules regarding Functional
Dependences (or relationship between attributes) to that relation.
Anomaly
Modification Anomalies
Anomaly
An error or inconsistency that may result when a user attempts to update a
table that contains redundant data.
There are three types of Anomaly - Insertion Anomaly, Deletion Anomaly,
Modification Anomaly
Well Structure Relation
A relation that contains minimal redundancy and allows users to insert, modify
and delete the rowswithout error or inconsistencies.
Racoosin Solutions
6
Example of Anomalies
Question – Is this a relation?
Answer – Yes: unique rows and no
multivalued attributes
Question – What’s the primary key? Answer – Composite: Emp_ID,
Course_Title
Racoosin Solutions
7
Anomalies in thisTable
 Insertion – can’t enter a new employee without having the employee take a class
 Deletion – if we remove employee 140, we lose information about the existence of a
Tax Acc class
 Modification – giving a salary increase to employee 100 forces us to update multiple
records
Why do these anomalies exist?
Because we’ve combined two themes (entity types) into one
relation. This results in duplication, and an unnecessary
dependency between the entities
Normal Forms
Normal Form Rules
• First Normal Form (1NF)
• Second Normal Form (2NF)
• Third Normal Form (3NF)
• Boyce-Codd Normal Form (BCNF)
• Fourth Normal Form (4NF)
Except 1NF each Normal Form
ensures it’s previous Normal Forms
are satisfied.
Normal Form : 1NF
First Normal Form (1NF)
First Normal Form Rule:
A relation that contains no multivalued Attributes.
- Before 1NF applied
.
employees
emp_id name dept_name salary course_title date_completed
100 M.S. MKT 48000
SPSS
Survey
8/9/16
10/7/16
140 A.B. ACC 52000 Tally ACC 12/8/16
110 C.L. I.S. 43000
SPSS
CTT
1/12/16
4/12/16
 First Normal Form (1NF)
- After 1NF
employees
emp_id name dept_name salary course_title date_completed
100 M.S. MKT 48000 SPSS 8/9/16
100 M.S. MKT 48000 Survey 10/7/16
140 A.B. ACC 52000 Tally ACC 12/8/16
110 C.L. I.S. 43000 SPSS 1/12/16
110 C.L. I.S. 43000 CTT 4/12/16
Normal Form : 2NF
Second Normal Form (2NF)
Second Normal Form Rule:
A relation in First Normal Form in which every attribute in fully
functionally dependent in the primary key or Partial Functional dependency
should be removed.
Partial Functional Dependency
A functional dependency in which one or more non-key attribute are
functionally dependent in part (but not all) of the primary key.
Functional Dependency
A constrain between two attribute or two sets of attributes.
 Second Normal Form (2NF)
- After 2NF
employees
emp_id name dept_name salary
100 M.S. MKT 68000
140 A.B. ACC 53000
120 C.L. IS 43000
Courses
emp_id course_title date_employed
100 SPSS 2/9/16
100 Survey 10/7/16
140 ACC 12/8/16
110 SPSS 1/12/16
110 CTT 4/12/16
Books
1. Modern Database Management (Sixth Edition) by Fred R. McFadden, Jeffrey A.
Hoffer, Mary B. Prescott
2. Database System Concepts (Fifth Edition) by Henry F. Korth, S. Sudarshan, A.
Silberschatz
3. Oracle-database-10g-sql-fundamentals-1-student-guide-volume-1
4. SQL and Relational Theory: How to Write Accurate SQL Code by C.J. Date
5. Database Systems: A Practical Approach to Design, Implementation and
Management (4th Edition) by Thomas M. Connolly, Carolyn E. Begg
6. Fundamentals of Database Systems, 5th Edition by RamezElmasri, Shamkant B.
Navathe
7. Database Design and Relational Theory: Normal Forms and All That Jazz by C. J. Date
8. An Introduction to Database Systems 8th Edition, by C.J. Date
References
1. https://www.db-book.com/db6/slide-dir/index.html
2. https://docs.oracle.com/en/database/oracle/oracle-database/20/sqlrf/SQL-
Standards.html#GUID-BCCCFF75-D2A4-43AD-8CAF-C3C97D92AC63
3. https://www.slideshare.net/HaaMeemMohiyuddin1/data-knowledge-and-
information
4. https://www.slideshare.net/tabinhasan/from-data-to-wisdom
5. https://www.slideshare.net/thinnaphat.bo/

Week9_Theory.pptx

  • 1.
    Normalization Course Code: CSC2108 Dept. of Computer Science Faculty of Science and Technology Lecturer No: 14 Week No: 09 Semester: TBA Lecturer: Name & email Course Title: Introduction to Database
  • 2.
    Lecture Outline 1. Introduction 2.The Normal Forms 3. Modification Anomalies 4. Real World Exercise
  • 3.
    Why Normalize?.. Why weneed this • Flexibility Structure supports many ways to look at the data • Data Integrity “Modification Anomalies” • Deletion • Insertion • Update • Efficiency Eliminate redundant data and save space
  • 4.
    Normalization Definition Normalization The process ofdecomposing relations with Anomalies to produce smaller Well- Structure relations. Normal Form A relation that results from applying simple rules regarding Functional Dependences (or relationship between attributes) to that relation.
  • 5.
    Anomaly Modification Anomalies Anomaly An erroror inconsistency that may result when a user attempts to update a table that contains redundant data. There are three types of Anomaly - Insertion Anomaly, Deletion Anomaly, Modification Anomaly Well Structure Relation A relation that contains minimal redundancy and allows users to insert, modify and delete the rowswithout error or inconsistencies.
  • 6.
    Racoosin Solutions 6 Example ofAnomalies Question – Is this a relation? Answer – Yes: unique rows and no multivalued attributes Question – What’s the primary key? Answer – Composite: Emp_ID, Course_Title
  • 7.
    Racoosin Solutions 7 Anomalies inthisTable  Insertion – can’t enter a new employee without having the employee take a class  Deletion – if we remove employee 140, we lose information about the existence of a Tax Acc class  Modification – giving a salary increase to employee 100 forces us to update multiple records Why do these anomalies exist? Because we’ve combined two themes (entity types) into one relation. This results in duplication, and an unnecessary dependency between the entities
  • 8.
    Normal Forms Normal FormRules • First Normal Form (1NF) • Second Normal Form (2NF) • Third Normal Form (3NF) • Boyce-Codd Normal Form (BCNF) • Fourth Normal Form (4NF) Except 1NF each Normal Form ensures it’s previous Normal Forms are satisfied.
  • 9.
    Normal Form :1NF First Normal Form (1NF) First Normal Form Rule: A relation that contains no multivalued Attributes. - Before 1NF applied . employees emp_id name dept_name salary course_title date_completed 100 M.S. MKT 48000 SPSS Survey 8/9/16 10/7/16 140 A.B. ACC 52000 Tally ACC 12/8/16 110 C.L. I.S. 43000 SPSS CTT 1/12/16 4/12/16
  • 10.
     First NormalForm (1NF) - After 1NF employees emp_id name dept_name salary course_title date_completed 100 M.S. MKT 48000 SPSS 8/9/16 100 M.S. MKT 48000 Survey 10/7/16 140 A.B. ACC 52000 Tally ACC 12/8/16 110 C.L. I.S. 43000 SPSS 1/12/16 110 C.L. I.S. 43000 CTT 4/12/16
  • 11.
    Normal Form :2NF Second Normal Form (2NF) Second Normal Form Rule: A relation in First Normal Form in which every attribute in fully functionally dependent in the primary key or Partial Functional dependency should be removed. Partial Functional Dependency A functional dependency in which one or more non-key attribute are functionally dependent in part (but not all) of the primary key. Functional Dependency A constrain between two attribute or two sets of attributes.
  • 13.
     Second NormalForm (2NF) - After 2NF employees emp_id name dept_name salary 100 M.S. MKT 68000 140 A.B. ACC 53000 120 C.L. IS 43000 Courses emp_id course_title date_employed 100 SPSS 2/9/16 100 Survey 10/7/16 140 ACC 12/8/16 110 SPSS 1/12/16 110 CTT 4/12/16
  • 14.
    Books 1. Modern DatabaseManagement (Sixth Edition) by Fred R. McFadden, Jeffrey A. Hoffer, Mary B. Prescott 2. Database System Concepts (Fifth Edition) by Henry F. Korth, S. Sudarshan, A. Silberschatz 3. Oracle-database-10g-sql-fundamentals-1-student-guide-volume-1 4. SQL and Relational Theory: How to Write Accurate SQL Code by C.J. Date 5. Database Systems: A Practical Approach to Design, Implementation and Management (4th Edition) by Thomas M. Connolly, Carolyn E. Begg 6. Fundamentals of Database Systems, 5th Edition by RamezElmasri, Shamkant B. Navathe 7. Database Design and Relational Theory: Normal Forms and All That Jazz by C. J. Date 8. An Introduction to Database Systems 8th Edition, by C.J. Date
  • 15.
    References 1. https://www.db-book.com/db6/slide-dir/index.html 2. https://docs.oracle.com/en/database/oracle/oracle-database/20/sqlrf/SQL- Standards.html#GUID-BCCCFF75-D2A4-43AD-8CAF-C3C97D92AC63 3.https://www.slideshare.net/HaaMeemMohiyuddin1/data-knowledge-and- information 4. https://www.slideshare.net/tabinhasan/from-data-to-wisdom 5. https://www.slideshare.net/thinnaphat.bo/