Biên soạn : ThS.Phan Võ Minh Thắng
1
Cơ sở Dữ liệu : Chuẩn hóa
Nh
Nh
ậ
ậ
p môn Cơ s
p môn Cơ s
ở
ở
D
D
ữ
ữ
li
li
ệ
ệ
u
u
Ph
Ph
ầ
ầ
n 5
n 5
–
–
Chu
Chu
a l
à
à
g
g
ì
ì
, vai trò c
, vai trò c
ủ
ủ
a n
a n
ó
ó
trong vi
trong vi
ệ
ệ
c
c
thi
thi
ế
ế
t k
t k
ế
ế
CSDL
á
ch chuy
ch chuy
ể
ể
n t
n t
ừ
ừ
d
d
ạ
ạ
ng chu
ng chu
ẩ
ẩ
n th
n th
ấ
ấ
p lên d
p lên d
ạ
ạ
ng
ng
chu
chu
ẩ
ó
ó
a
a
v
v
à
à
vi
vi
ệ
ệ
c
c
mô
mô
h
h
ì
ì
nh
nh
E
E
-
-
R
R
đư
đư
đ
đ
ể
ể
th
th
ự
ự
c
c
hi
hi
ệ
ệ
n
n
t
t
ố
ố
t
t
vi
vi
ệ
ệ
c
c
thi
thi
ng
ng
h
h
ợ
ợ
p
p
yêu
yêu
c
c
ầ
ầ
u
u
ph
ph
ả
ả
i
i
de
de
-
-
normalization
normalization
đ
đ
u
u
qu
qu
ả
ả
Biên soạn : ThS.Phan Võ Minh Thắng
4
Cơ sở Dữ liệu : Chuẩnhóa
C
C
á
á
c
c
b
b
ả
ả
ng
ng
trong
trong
CSDL
CSDL
v
v
à
à
s
à
nh
nh
ph
ph
ầ
ầ
n
n
cơ
cơ
s
s
ở
ở
trong
trong
thi
thi
ế
ế
t
t
k
k
ế
ế
CSDL
CSDL
•
quan
tâm
tâm
h
h
à
à
ng
ng
đ
đ
ầ
ầ
u
u
•
•
C
C
ó
ó
hai
hai
trư
trư
ờ
ờ
ng
ng
h
n
t
t
ạ
ạ
i
i
c
c
á
á
c
c
b
b
ả
ả
ng
ng
c
c
ó
ó
c
c
ấ
ấ
u
u
tr
ợ
p
p
lý
lý
–
–
Hi
Hi
ệ
ệ
u
u
ch
ch
ỉ
ỉ
nh
nh
CSDL
CSDL
s
s
ẵ
ẵ
n
n
c
c
ó
ng
không
không
t
t
ố
ố
t
t
•
•
Chu
Chu
ẩ
ẩ
n
n
h
h
ó
ó
a
a
c
c
ó
ó
th
th
ể
ả
ng
ng
c
c
ó
ó
c
c
ấ
ấ
u
u
tr
tr
ú
ú
c
c
không
không
t
t
ố
ố
t
t
v
v
à
c
ó
ó
c
c
ấ
ấ
u
u
tr
tr
ú
ú
c
c
t
t
ố
ố
t
t
hơn
hơn
Biên soạn : ThS.Phan Võ Minh Thắng
5
Cơ sở Dữ liệu : Chuẩnhóa
C
C
á
á
a
a
•
•
Chu
Chu
ẩ
ẩ
n
n
h
h
ó
ó
a
a
l
l
à
à
qu
qu
á
á
tr
tr
ì
ì
nh
nh
c
c
th
th
ự
ự
c
c
th
th
ể
ể
–
–
Gi
Gi
ả
ả
m
m
dư
dư
th
th
ừ
ừ
a
a
d
d
á
á
c
c
th
th
ự
ự
c
c
th
th
ể
ể
–
–
Gi
Gi
ú
ú
p
p
lo
lo
ạ
ạ
i
i
b
b
a
a
đư
đư
ợ
ợ
c
c
ki
ki
ể
ể
m
m
so
so
á
á
t
t
đ
đ
ể
ể
liên
liên
k
k
ế
ế
chi
chi
ph
ph
í
í
x
x
ử
ử
lý
lý
hơn
hơn
–
–
Tr
Tr
ả
ả
i
i
qua
qua
m
m
ộ
ộ
t
t
d
d
ạ
ạ
ng
ng
chu
chu
ẩ
ẩ
n
n
Biên soạn : ThS.Phan Võ Minh Thắng
6
Cơ sở Dữ liệu : Chuẩnhóa
Database Tables and
Database Tables and
Normalization
Normalization
•
•
C
C
á
á
c
c
giai
giai
đo
-
Second normal form
Second normal form
–
–
3NF
3NF
-
-
Third normal form
Third normal form
–
–
4NF
4NF
-
-
Fourth normal form
Fourth normal form
Better in
dependency
Worse in
performance
(I/O)
Business
Bioinformatics
Statistical data
Biên soạn : ThS.Phan Võ Minh Thắng
7
Cơ sở Dữ liệu : Chuẩnhóa
ự
ự
ng
ng
–
–
Building projects
Building projects
•
•
Project number
Project number
•
•
Project name
Project name
•
•
Employees assigned
Employees assigned
•
•
…
…
–
–
Employee
Employee
•
•
qu
ả
ả
quan
quan
s
s
á
á
t
t
t
t
ừ
ừ
h
h
ì
ì
nh
nh
4.1
4.1
•
•
PRO_NUM intended to be primary key, but
PRO_NUM intended to be primary key, but
it contains null values.
it contains null values.
•
ì
ì
nh
nh
4.1
4.1
•
•
Table displays data redundancies which
Table displays data redundancies which
yield the following anomalies
yield the following anomalies
–
–
Update
Update
•
•
Modifying JOB_CLASS
Modifying JOB_CLASS
–
–
Insertion
Insertion
•
•
New employee must be assigned project (phantom
New employee must be assigned project (phantom
project)
project)
Repeating groups must be eliminated
–
–
Proper primary key developed
Proper primary key developed
•
•
Uniquely identifies attribute values (rows)
Uniquely identifies attribute values (rows)
•
•
Combination of PROJ_NUM and EMP_NUM
Combination of PROJ_NUM and EMP_NUM
Biên soạn : ThS.Phan Võ Minh Thắng
15
Cơ sở Dữ liệu : Chuẩnhóa
Conversion to 1NF
Conversion to 1NF
•
•
Repeating groups must be eliminated
Repeating groups must be eliminated
–
–
Dependencies can be identified
Dependencies can be identified
–
–
Desirable dependencies based on primary key
Desirable dependencies based on primary key
Composite primary key
Biên soạn : ThS.Phan Võ Minh Thắng
17
Cơ sở Dữ liệu : Chuẩnhóa
PROJ_NUM,EMP_NUM Æ PROJ_NAME, EMP_NAME,
JOB_CLASS,CHG_HOUR, HOURS
PROJ_NUM Æ PROJ_NAME
DESIRED DEPENDENCIES
EMP_NUM Æ EMP_NAME, JOB_CLASS, CHG_HOUR
PARTIAL DEPENDENCIES
JOB_CLASS -> CHG_HOUR
TRANSITIVE DEPENDENCIES
Biên soạn : ThS.Phan Võ Minh Thắng
18
Cơ sở Dữ liệu : Chuẩnhóa
1NF Summarized
1NF Summarized
•
•
All key attributes defined
All key attributes defined
•
•
No repeating groups in table
No repeating groups in table
•
•
All attributes dependent on
All attributes dependent on
primary key
20
Cơ sở Dữ liệu : Chuẩnhóa
2NF Conversion Results
2NF Conversion Results
Figure 4.5
Biên soạn : ThS.Phan Võ Minh Thắng
21
Cơ sở Dữ liệu : Chuẩnhóa
2NF Summarized
2NF Summarized
•
•
In 1NF
In 1NF
•
•
Includes no partial dependencies
Includes no partial dependencies
–
–
No attribute dependent on a portion of primary
No attribute dependent on a portion of primary
key
key
•
•
Still possible to exhibit transitive
Still possible to exhibit transitive
dependency
dependency
3NF Summarized
3NF Summarized
•
•
In 2NF
In 2NF
•
•
Contains no transitive
Contains no transitive
dependencies
dependencies
Biên soạn : ThS.Phan Võ Minh Thắng
24
Cơ sở Dữ liệu : Chuẩnhóa
Additional DB Enhancements
Additional DB Enhancements
Figure 4.6
Biên soạn : ThS.Phan Võ Minh Thắng
25
Cơ sở Dữ liệu : Chuẩnhóa