Académique Documents
Professionnel Documents
Culture Documents
p 312
Chapter 10-1
10.3.1 Normalization of Relations
Chapter 10-2
10.3.2 Practical Use of Normal Forms
Chapter 10-3
10.3.2 Practical Use of Normal Forms
Chapter 10-4
An Unnormalized Relation
An unnormalized table contains one or more repeating groups.
Chapter 10-5
10.3.2 First Normal Form (1NF)
Chapter 10-6
Figure 10.8 Normalization into 1NF
Chapter 10-7
Problem
Chapter 10-8
Figure 10.8 Normalization into 1NF
p 137
Chapter 10-9
Video Rental Example
Unnormalized RENTAL table
RENTAL
transId, date, customerId, name, address, city, state, zip,
videoId, copy#, title, rentAmount,
videoId, copy#, title, rentAmount,
videoId, copy#, title, rentAmount
To put it into 1NF, remove the repeating group to its own table.
Chapter 10-10
Video Rental Example
1NF RENTAL table
RENTAL
transId, date, cusId, name, address, city, state, zip
RENTAL_ITEM COPY
transId, videoId, copy#, title, rentAmount videoId, #copies
Chapter 10-12
Notes
Chapter 10-13
10.3.3 Second Normal Form (2NF)
RENTAL_ITEM
transId videoId copy# title rent
101 15 1 Matrix 1.50
101 12 5 Hopscotch 1.00
Chapter 10-14
Problems with 1NF
Consider:
RENTAL_ITEM
transId videoId copy# title rent
101 15 1 Matrix 1.50
101 12 5 Hopscotch 1.00
Chapter 10-15
Keys and Attributes Participating in Keys
(1/2)
Chapter 10-16
You're telling me about
superkeys? SUPERKEYS?!
Ralph, there's nothing new
here. It just means that no
two rows can be the same
for the set of superkey
attributes. Call me back
when you have something
new.
Chapter 10-17
SuperKey
A superkey of a relation schema R = {A1, A2, ....,
An} is a set of attributes S subset-of R with the
property that no two tuples t1 and t2 in any legal
relation state r of R will have t1[S] = t2[S]
Chapter 10-19
Key
Given the following table, identify the
following:
Candidate key
Primary key
Secondary key
Prime attributes
Non-prime attributes
RENTAL_ITEM
transId videoId copy# title rent
101 15 1 Matrix 1.50
101 12 5 Hopscotch 1.00
Chapter 10-20
Functional Dependency
Functional dependency -
denoted A -> B ("A functionally determines B")
between two sets of attributes A and B means that
the values of the A component uniquely determine
the values of the B component.
Chapter 10-21
Functional Dependency
Functional dependency -
denoted A -> B ("A functionally determines B")
between two sets of attributes A and B means that
the values of the A component uniquely determine
the values of the B component.
Chapter 10-22
Functional Dependency
Functional dependency -
Describes a relationship between attributes in
a relation.
For example, if A and B are attributes of relation R,
B is functionally dependent on A,
denoted A -> B,
if each value of A is associated with exactly one
value of B.
Chapter 10-23
Functional Dependency
For example, if A and B are attributes of relation R,
"A functionally determines B",
or "B is functionally dependent on A",
denoted A -> B,
if each value of A is associated with exactly one
value of B.
RENTAL_ITEM
transId videoId copy# title rent
101 151 1 Matrix 1.50
101 127 5 Hopscotch 1.00
Identify a functional dependency in RENTAL_ITEM
Chapter 10-24
Functional Dependency
RENTAL_ITEM
transId videoId copy# title rent
101 151 1 Matrix 1.50
101 127 5 Hopscotch 1.00
1 1
videoId title
Chapter 10-25
Functional Dependency
RENTAL_ITEM
transId videoId copy# title rent
101 151 1 Matrix 1.50
101 127 5 Hopscotch 1.00
102 163 1 Matrix 1.50
Title is functionally dependent on videoId.
For each videoId=151 there is only one title value ("Matrix").
If you know the videoId, you always know the title.
We find only one title=Matrix whenever videoId=151
We find only one title=Matrix whenever videoId=163
videoId functionally determines title.
n 1
videoId title
Chapter 10-26
Not Functionally Dependent
RENTAL_ITEM
transId videoId copy# title rent
101 151 1 Matrix 1.50
101 151 5 Hopscotch 1.00
102 163 1 Matrix 1.50
n n
videoId title
Chapter 10-27
Functional Dependency
RENTAL_ITEM
transId videoId copy# title rent
101 151 1 Matrix 1.50
101 151 5 Hopscotch 1.00
102 163 1 Matrix 1.50
1 n
videoId n n title
Chapter 10-28
Functional Dependency (FD)
The Rental_ITEM table is in 1NF, but not in 2NF
RENTAL_ITEM
is FD on
is FD on
is FD on
Chapter 10-30
2NF
RENTAL_ITEM VIDEO
is FD on
is FD on
is FD on
Definitions:
Full functional dependency - a FD Y -> Z
where removal of any attribute from Y means the
FD does not hold any more
Examples:
{SSN, PNUMBER} -> HOURS is a full FD since neither SSN
-> HOURS nor PNUMBER -> HOURS hold
Chapter 10-32
Figure 10.10 Normalizing into 2NF and
3NF
Chapter 10-33
Fig10.10 Normalizing into 2NF and 3NF
Chapter 10-34
Figure 10.11 Normalization into 2NF and
3NF
Chapter 10-35
Fig 10.11 Normalization into 2NF and 3NF
Chapter 10-36
Functional Dependencies
RENTAL
transId, date, cusId, name, address, city, state, zip
FD on transId
FD on cusId
Chapter 10-39
10.3.4 Third Normal Form (3NF)
Definition:
Transitive functional dependency - a FD X -> Z
that can be derived from two FDs X -> Y and Y -> Z
Examples:
- SSN -> DMGRSSN is a transitive FD since
SSN -> DNUMBER and DNUMBER -> DMGRSSN
hold
- SSN -> ENAME is non-transitive since there is no set
of attributes X where SSN -> X and X -> ENAME
Chapter 10-40
Third Normal Form (2/2)
Chapter 10-41
3NF
RENTAL CUSTOMER
FD on transId
FD on cusID
Chapter 10-42
Notes
Chapter 10-43
Notes
Chapter 10-44
10.3.1 Normalization of Relations
Chapter 10-45
10.4 General Normal Form Definitions (For Multiple
Keys) (1)
Chapter 10-46
General Normal Form Definitions (2)
Definition:
Superkey of relation schema R - a set of attributes
S of R that contains a key of R
A relation schema R is in third normal form
(3NF) if whenever a FD X -> A holds in R, then
either:
(a) X is a superkey of R, or
(b) A is a prime attribute of R
NOTE: Boyce-Codd normal form disallows condition (b)
above
Chapter 10-47
5 BCNF (Boyce-Codd Normal Form)
Chapter 10-48
Figure 10.12 Boyce-Codd normal form
Chapter 10-51
Achieving the BCNF by Decomposition (2)
Chapter 10-52
Chapter 10
Chapter 10-55
Figure10.9 Normalizing nested
relations into 1NF. (a) Schema of
the EMP_PROJ relation with a
“nested relation” attribute PROJS.
(b) Example extension of the
EMP_PROJ relation showing nested
relations within each tuple. (c)
Decomposition of EMP_PROJ into
relations EMP_PROJ1 and
EMP_PROJ2 by propagating the
primary key.
Chapter 10-56
Figure10.10
Normalizing into 2NF
and 3NF.
(a) Normalizing
EMP_PROJ into 2NF
relations
(b) Normalizing
EMP_DEPT into 3NF
relations.
Chapter 10-57
Figure 10.11
Normalization into 2NF and 3NF.
(a) the LOTS relation with its
functional dependencies FD1
though FD4. (b) Decomposing
into the 2NF relations LOTS1 and
LOTS2.
(c) Decomposing LOTS1 into the
3NF relations LOTS1A and
LOTS1B. (d) Summary of the
progressive normalization of
LOTS.
Chapter 10-58
p 137
Chapter 10-59
Out
Chapter 10-60
Figure 10.9 Normalization nested relations into 1NF
p 317
Chapter 10-61
Exercise 10.32
Chapter 10-63
p. 139
Chapter 10-64