DBD261 SLID 03 Normalization
DBD261 SLID 03 Normalization
Database design
Belgium Campus – DBD261 – lesson 3
NormaliZation
Normalization
THE FORMAL APPROACH TO APPLYING A SET OF RULES USED TO ASSOCIATE ATTRIBUTES WITH ENTITIES.
BENEFITS
4
www.belgiumcampus.ac.za
Data Redundancy
• Unnecessarily storing same data at different places
• Islands of information: Scattered data locations
• Increases the probability of having different versions of the same data
55
www.belgiumcampus.ac.za
Normalization Process
• Objective is to ensure that each table conforms to the concept of
well-formed relations
• Each table represents a single subject
• No data item will be unnecessarily stored in more than one table
• All non-key attributes in a table are dependent on the primary key
• Each table is void of insertion, update, and deletion anomalies
6
www.belgiumcampus.ac.za
Data ANOMALIES
• The dictionary defines anomaly as “an abnormality.”
• Ideally, a field value change should be made in only a single place.
• Data redundancy, however, fosters an abnormal condition by forcing
field value changes in many different locations
7
www.belgiumcampus.ac.za
Types of Data Anomaly
Update Anomalies
Insertion Anomalies
Deletion Anomalies
88
www.belgiumcampus.ac.za
Types of Data
Anomaly
• Update Anomaly – changes ENO NAME BRANCH HOD OFFICE_TEL
to OFFICE_TEL of branch CSE
requires updates to all 401 Akon CSE Mr. X 53337
instances of CSE
402 Bkon CSE Mr. X 53337
• Insertion Anomaly – adding a
new branch require values 403 Ckon CSE Mr. X 53337
for employee number (ENO) 404 Dkon CSE Mr. X 53337
and NAME.
405 Ekon MCE Mr. Y 53330
• Deletion Anomaly – deleting
employee 405 will also
delete branch MCE • What other problems can you identify with this table?
• Classify each of the problems as an Update, Insertion
or Deletion anomaly
9 9
www.belgiumcampus.ac.za
Keys
• Consist of one or more attributes that determine other attributes
• Used to:
• Ensure that each row in a table is uniquely identifiable
• Establish relationships among tables and to ensure the integrity of the data
• Primary key (PK): Attribute or combination of attributes that
uniquely identifies any given row
10
10
www.belgiumcampus.ac.za
Determination
• State in which knowing the value of one attribute makes it possible to
determine the value of another
• Is the basis for establishing the role of a key
• Based on the relationships among the attributes
11
11
www.belgiumcampus.ac.za
Dependencies
• Functional dependence: Value of one or more attributes determines
the value of one or more other attributes
• Determinant: Attribute whose value determines another
• Dependent: Attribute whose value is determined by the other attribute
• Full functional dependence: Entire collection of attributes in the
determinant is necessary for the relationship
12
12
www.belgiumcampus.ac.za
Types of Functional Dependencies
• Partial dependency: Functional dependence in which the
determinant is only part of the primary key
• Assumption - One candidate key
• Straight forward
• Easy to identify
• Transitive dependency: An attribute functionally depends on another
non-key attribute
13
www.belgiumcampus.ac.za
Normalization Process
• Ensures that all tables are in at least 3NF
• Higher forms are not likely to be encountered in business
environment
• Works one relation at a time
• Starts by:
• Identifying the dependencies of a relation (table)
• Progressively breaking the relation into new set of relations
14
www.belgiumcampus.ac.za
15
City
DegreeName
DegreeWhenEarned
DegreeInProgress
Conversion to First Normal Form
• Repeating group: Group of multiple entries of same type can exist for
any single key attribute occurrence
• Existence proves the presence of data redundancies
• Enable reducing data redundancies
• Steps
• Eliminate the repeating groups
• Identify the primary key
• Identify all dependencies
16
www.belgiumcampus.ac.za
17
Student
StudentID
First Firstname
Lastname
normal MiddelInitial
BillingAddress1 Student
18
www.belgiumcampus.ac.za
19
Student
Second StudentID(PK)
normal
Firstname
Lastname
form MiddelInitial
StudentDegree
StudentID (FK)
BillingAddress1
DegreeID (FK) Degree
BillingCity
A relationship is in the DegreeID (PK)
BillingProvince
second normal form
(2NF) if it is in the first BillingPostCode
In the StudentDegree table DegreeName
HostelStreet
HostelPhone
HostelRoomNumber
Conversion to Third Normal Form
• Steps
• Make new tables to eliminate transitive dependencies
• Determinant: Any attribute whose value determines other values within a row
• Reassign corresponding dependent attributes
• Table is in 3NF when it:
• Is in 2NF
• Contains no transitive dependencies
20
www.belgiumcampus.ac.za
21
Student
Third StudentID(PK) Degree
normal Firstname
Lastname
StudentDegree
StudentID (FK)
DegreeID (PK)
DegreeName
HostelRoomNumber
Normalization and Database Design
• Normalization should be part of the design process
• Proposed entities must meet required the normal form before table
structures are created
• Principles and normalization procedures to be understood to redesign
and modify databases
• ERD is created through an iterative process
• Normalization focuses on the characteristics of specific entities
22
www.belgiumcampus.ac.za
Denormalization
• Design goals
• Creation of normalized relations
• Processing requirements and speed
• Number of database tables expands when tables are decomposed to
conform to normalization requirements
• Joining a larger number of tables:
• Takes additional input/output (I/O) operations and processing logic
• Reduces system speed
23
www.belgiumcampus.ac.za
Denormalization
• Defects in unnormalized tables
• Data updates are less efficient because tables are larger
• Indexing is more cumbersome
• No simple strategies for creating virtual tables known as views
24
www.belgiumcampus.ac.za
DISCUSSION
• Discuss the motivation for and against de-normalizing a database.
25
www.belgiumcampus.ac.za
26
Activity
Complete DBD2x1 Activity 2 -
Normalization
GET READY
Download and install SQL Server
Express edition on your PC