Académique Documents
Professionnel Documents
Culture Documents
Module 4
NormalizationNormalization- Definition
Definition
NormalizationNormalization- Overview
Overview
Reduce the amount of space a database consumes and ensure that data is
logically stored.
It is part of successful database design.
Without normalization, database systems can be
-
inaccurate,
slow,
and inefficient
and they might not produce the data you expect.
What
What Should
Should we
we achieve
achieve when
when normalizing
normalizing a
a
database?.
database?.
Arranging data into logical groups
Minimizing the amount of duplicated data
Access and manipulate the data quickly and efficiently
Make the changes in only one place
PS: Sometimes database designers refer to these goals in terms
such as data integrity, referential integrity, or keyed data access.
NormalizationNormalization- Overview
Overview
Goals
Goals of
of Normalisation
Normalisation
Update
Update anomalies
anomalies
SSN
987
654
333
321
678
467
Name
J Smith
M Burke
A Dolan
K Doyle
O ONeill
R McKay
Dept
1
2
1
1
3
2
467
...
321
321
678
467
Representing
Department info
in the Employee
table causes
problems.
Sample
Sample anomalies
anomalies
Modification when the manager of a dept changes we have to change many values.
If we are not careful the DB will contain inconsistencies.
There is no easy way to get the DB to ensure that a department has only
one manager and only one name.
Anomalies
Anomalies continued
continued
Insertion
how would we create a new department before any employees are
assigned to it ?
Better
Better design
design
SSN
987
654
333
321
678
467
Name
J Smith
M Burke
A Dolan
K Doyle
O ONeill
R McKay
Dept
1
2
1
1
3
2
Dept
1
2
3
467
...
678
10
Poor
Poor database
database design
design usually
usually include
include
Repetition of information
Loss of information
11
Normalization
Normalization stages
stages
12
Un
Un Normalized
Normalized Form
Form
13
First
First Normal
Normal Form
Form
Update
Modifying JOB_CLASS
Insertion
New employee must be assigned project
Deletion
If employee deleted, other vital data lost
14
First
First Normal
Normal Form
Form (FNF)
(FNF)
15
First
First Normal
Normal Form
Form
16
After
After 11 NF
NF Data
Data
17
18
Second
Second Normal
Normal Form
Form
19
Second
Second Normal
Normal Form
Form
20
Steps
Steps of
of Second
Second Normal
Normal Form
Form
21
22
Data
Data After
After Second
Second Normal
Normal Form
Form
23
Second
Second Normal
Normal Form
Form Summary
Summary
24
Third
Third Normal
Normal Form
Form
25
Third
Third Normal
Normal Form
Form
26
After
After 33 NF
NF Data
Data
In 2NF Contains no transitive dependencies
27
After
After Third
Third Normal
Normal Form
Form
28
Boyce-Codds
Boyce-Codds Normal
Normal Form
Form
After a lot of other approaches Boyce and Codd noticed a simple rule
for ensuring tables are well-normalised. Tables which obey the rule
are in BCNF (Boyce Codd Normal Form).
BCNF rule:
Every determinant in a table must be a candidate key for that
table.
29
Determinants
Determinants
30
Determinants
Determinants
Alternative terminology
if A (functionally) determines B then
B is (functionally) dependent on A
31
Example
Example determinants
determinants
32
Determinacy
Determinacy Diagram
Diagram
Name
SSN
Department
Dept. Name
Dept. Mgr
33
Composite
Composite Determinants
Determinants
Name
SSN
hours
Project#
PName
34
Transitive
Transitive Dependencies
Dependencies
DeptNo
SSN
Dept. Mgr
35
Candidate
Candidate keys
keys
36
Finding
Finding candidate
candidate keys
keys
Name
(SSN, Project#) is a
(composite) candidate
key for a table
containing these five
attributes.
SSN
hours
Project#
PName
37
What
What are
are the
the candidate
candidate keys
keys ??
E
P
M
N
S
W
T
V
K
teacher
subject
D
F
student
H
X
Y
A
B
C
38
Problems
Problems occur
occur when
when ...
...
SSN
Name
DeptNo
Dept. Name
Dept. Mgr
SSN, DeptNo and DeptName are
determinants
they have arrows coming out of them.
39
BCNF
BCNF rule
rule
SSN
Name
DeptNo
DeptNo
Dept. Name
Dept. Mgr
Transformation
Transformation to
to BCNF
BCNF
W
Z
X
Y
A
B
C
V
X
W
B
C
BCNF tables :
(V, X)
(A, B, C)
(V, W, Z, A)
(V, W, Y)
41
Summarizing
Summarizing Normal
Normal Forms
Forms
Table is in 2NF
but not 3NF
42
BCNF
BCNF vs.
vs. 3NF
3NF
teacher
student
teacher
subject
3NF, not BCNF
keys: (student, subject)
(student, teacher)
teacher is a determinant
teacher
subject
BCNF
but tables are not independent
43
Further
Further Normalization
Normalization
4NF
The table should be In BCNF
The table should not Contain any multi-valued / nontrivial dependency
5NF
The table should be In 4NF
The Table should not have any join dependencies
44
Normalization
Relational db model
1st Normal Form
2nd Normal Form
3rd Normal Form
Boyce/Codd Normal Form
4th Normal Form
5th Normal Form
Normalized relational db
model
45
Denormalization
46
Denormalization
Demoralization is the process of attempting to optimize the performance
of a database by adding redundant data
This may achieve (may not!) an improvement in query response, but
at a cost
There should be a new set of constraints added that specify how the
redundant copies of information must be kept synchronized
Denormalization can be hazardous
47
On
On lighter
lighter Note
Note
48
49
End;
50
Codds
Codds Rules
Rules
proposed by Edgar F. "Ted" Codd, a pioneer of the
relational model for databases,
Rule 0: The system must qualify as relational, as a
database, and as a management system.
For a system to qualify as a RDBMS, that system must use its
relational facilities (exclusively) to manage the database
51
Codds
Codds Rules
Rules (Cont.)
(Cont.)
52
Codds
Codds Rules
Rules (Cont.)
(Cont.)
Codds
Codds Rules
Rules (Cont.)
(Cont.)
This rule states that insert, update, and delete operations should be supported for
any retrievable set rather than just for a single row in a single table.
54
Codds
Codds Rules
Rules (Cont.)
(Cont.)
Codds
Codds Rules
Rules (Cont.)
(Cont.)
56