CMPG213SU8Normalization2020 Compressed
CMPG213SU8Normalization2020 Compressed
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved.
Steps to draw a Datamodel
8-2
Identify relationships between each
pair of Entities
• Define cardinality (1-to-1 OR 1-to-many OR many-to-many)
• Indicate FK
• If 1-to-1, PK of one entity becomes FK in other
entity (result should have minimum null values)
• If 1-to-M, PK of one entity becomes FK in M entity
• If M-to-M, create NEW entity with PK containing at
least both entities’ PKs
• Determine if relationship is WEAK or STRONG
• If PK of 1-Entity appears in PK of M-Entity, then M-Entity =
WEAK and relationship = STRONG (identifying)
• If PK of 1-Entity does not appear in PK of M-Entity, then M-
Entity = STRONG and relationship = WEAK (non-
identifying)
8-3 • Define verbs
Normalization
• Evaluating and correcting table structures
to minimize data redundancies
• Reduces data anomalies
(onreëlmatighede)
• Assigns attributes to tables based on
determination (Key)
• Normal forms
• First normal form (1NF)
• Second normal form (2NF)
• Third normal form (3NF)
Conversion to First Normal
Form
• Steps
• Eliminate the repeating groups
• Eliminate attributes with more than one value
• Identify the primary key
8-5
Example of Repeating Groups
8-6
Example of attribute with more
than one value
Book Title Author
Number
9781408048634 Database Coronel, Morris, Rob,
Principles Crockett
8-7
Conversion to First Normal
Form
8-8
First Normal Form (1NF)
Dependency Diagram
8-9
Conversion to Second Normal
Form
Table is in 2NF when it:
Is in 1NF
Includes no partial dependencies
Steps
Make new tables to eliminate partial dependencies
Reassign corresponding dependent attributes
When a table has a single attribute PK, the table is
automatically in 2NF if it is in 1NF
8-10
Second Normal Form (2NF)
Conversion Results
8-11
Conversion to Third Normal
Form
Table is in 3NF when it:
Is in 2NF
Contains no transitive dependencies
Steps
Make new tables to eliminate transitive
dependencies
Primary Key: Any attribute whose value determines other
values within a row
Reassign corresponding dependent attributes
8-12
Third Normal Form (3NF)
Conversion Results
8-13
Class Test
‘n IT maatskappy hou detail in stand van alle sagteware
projekte waarin hulle werknemers op die oomblik betrokke
is. Die detail bestaan uit die volgende attribute: / An IT
company maintains details of all the software projects in
which its employees are currently involved. These details
comprise the following attributes:
• Werknemer nommer / Employee number
• Werknemer naam / Employee name
• Geboortedatum / Date of birth
• Departement kode / Department code
• Departement naam / Department name
• Projek kode / Project code
• Projek beskrywing / Project description
8-14 • Projek toesighouer / Project supervisor
Classwork
Aanvaar die volgende: / Assume the following:
• Elke werknemer nommer is uniek. / Each employee number is unique.
• Elke departement het ‘n unieke departement kode. / Each department has a
unique department code.
• Elke projek het ‘n unieke projek kode en unieke toesighouer met naam en van.
/ Each project has a unique project code and unique supervisor with name and
lastname.
• Elke werknemer werk in ‘n enkele departement, maar elke departement het
baie werknemers. / Each employee works in a single department but every
department has many employees.
• Elke werknemer mag op een of meer projekte werk. / Each employee may
work on one or more projects.
• Elke projek het een of meer werknemers wat daarop werk. / Each project has
one or more employees working on it.
• Werknemer name is nie uniek nie. / Employee names are not unique.
Normaliseer hierdie data tot 3NF. / Normalise this data to 3NF.
8-15
Classwork Memo
EMPLOYEEOnPROJECT
(Employee Number (PK) (FK) , Project Code (PK) (FK) )