Normalization
Normalization
Closure Set
(STUD_NO)+ = {STUD_NO, STUD_NAME, STUD_PHONE,
STUD_STATE, STUD_COUNTRY, STUD_AGE}
(STUD_STATE)+ = {STUD_STATE, STUD_COUNTRY}
Abbreviations Meaning
A Employee no
B Dept no
C Manager’s emp no
D Proj no directed by that manager
E Dept name
F Time allocated to specified proj
Abbreviations Meaning
A BC Employee no Deptno,
Manager’s emp no
BE Dept no Dept name
CD EF Manager’s emp no, Proj no
directed by that manager
Dept name, Time allocated to
specified proj
We now show that FD (AD F) holds in R
Similarly, as CD EF (given)
So AD EF (3 and 4, transitivity)
Hence, AD F (5, decomposition)
Example:
Example:
Functional Dependencies
staffNo job
staffNo dept
staffNo dname
dept dname
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Steps in normalization
Normal form:
Condition using keys and FDs of a relation to
certify whether a relational schema is in a
particular normal form
Composite
Primary
Key
STUDENT
STUDENT
Stud_ID Name
101 Lennon
125 Jonson
STUDENT_COURSE
Composite
Primary
Key
STUDENT
STUDENT
Student
Stud_ID Course_ID
Stud_ID Name Course_ID Units 101 MSI 250
101 Lennon MSI 250 3.00
101 Lennon MSI 415 3.00
101 MSI 415
125 Johnson MSI 331 3.00
125 MSI 331
STUDENT COURSE
Transitive
Dependency
EMPLOYEE
EMPLOYEE
EMPLOYEE
DEPARTMENT
Dept_ID Dept_Name
1 Acct
2 Mktg
S1 20 London P2 2000
S2 10 Paris P2 500
S3 20 London P3 3000
Test of 2NF
{S#} -> {STATUS, CITY}: partial dependencies.
FIRST is in 1NF, but not in 2NF.
Decomposition:
SECOND {S#, STATUS, CITY}
SP {S# (FK: references SECOND), P#, QTY}
Test of 3NF:
{S#} -> {CITY} -> {STATUS}: transitive dependency
SECOND is in 2NF, but not 3NF.
Decomposition:
CS {CITY, STATUS}
SC {S#, CITY (FK: references CS)}
S2 10 Paris S1 P2 2000
S3 20 London S2 P2 500
S3 P3 3000
Note: Relation Two is in 3NF (with only one non-key field),
but relation One is not in 3NF because Status is dependent
on City (both are non-key fields)
Unnormalised
(UDF) Remove repeating groups
Anomalies:
- PK: combination of StdSSN and OfferNo
- Insert: cannot insert a new student without enrolling in an
offering (OfferNo part of PK)
- Update: change a course description; change every
enrollment of the course
- Delete: remove third row; lose information about course C3
Table has obvious redundancies
Easier to query: no joins
More difficult to change: can work around problems
(dummy PK) but tedious to do
Identify FDs
Determine whether FDs meet normal form
Split the table to meet the normal form if there is a
violation
2. Add to this relation a copy of the PK of the relation immediately enclosing it.
ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total
(order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
(prod-desc, unit-price)
2. Add to this relation a copy of the attribute(s) which determines these offending
attributes. These will automatically become the primary key of this new relation..
ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total)
(prod-no, prod-desc, unit-price)
1. Remove the offending attributes that are transitively dependent on non-key attributes,
and place them in a new relation.
ORDER-2 (order-no, order-date, cust-no, order-total
(cust-name, cust-add )
2. Add to this relation a copy of the attribute(s) which determines these offending
attributes. These will automatically become the primary key of this new relation..
ORDER-2 (order-no, order-date, cust-no, order-total
order-no prod-no
ORDER PRODUCT
shows
places placed by contains belongs to
cust-no order-no, prod-no
CUSTOMER
part of ORDER-LINE