4-1 - NormalizationWT
4-1 - NormalizationWT
Walk-Through
Steps in Normalization
Normalization can be accomplished in stages, each of which
corresponds to a normal form
Customer ID : 22
Customer Name : Dan’s Furniture
Customer Address : Fullerton, California
Customer ID : 65
Customer Name : Furniture Barn
Customer Address : Fort Collins, Colorado
Customer ID : 65
Customer Name : Furniture Barn
Customer Address : Fort Collins, Colorado
Order Order Cust ID Cust Cust Prod Product Prod Unit Ordered
ID Date Name Address ID Description Finish Price Qty
Order ID Order Cust Customer Customer Prod Product Prod Unit Ordered
Date ID Name Address ID Description Finish Price Qty
1006 24 Oct 22 Dan’s Fullerton, 7 Tea Table Walnut $450 2
2019 Furniture CA
1006 24 Oct 22 Dan’s Fullerton, 5 TV Stand Oak $300 6
2019 Furniture CA
1006 24 Oct 22 Dan’s Fullerton, 4 Porch Swing Pine $800 5
2018 Furniture CA
1007 31 Oct 65 Furniture Ft. Collin,Co 11 Table Cherry $1150 3
2019 Barn
1007 31 Oct 65 Furniture Ft. Collin,Co 4 Porch Swing Pine $800 7
2019 Barn
Table with multivalued Attributes:
Not in 1 Normal Form
st
PatientID PatienName PatientAdd PatientCPNo
P101 Bea Makati 091777
092677
P102 Liza Manila 091933
092433
PatientID PatienName PatientAdd PatientCPNo
P103 Kim Mandaluyong 091801
097702 P101 Bea Makati 091777
P Q R S T DECOMPOSE relation R
R1(P, R)
partial FD
R2(P, Q, T)
PR is the candidate key
R3(R, S)
example 3
1 3 5 3 Nayre 1 Bea
Sid Sname Tid Tname Grade 2 2 4 2 Dastas 2 Angel
3 1 6 1 Cruz 3 Ivana
partial FD partial FD
Order Order Cust Customer Customer Prod Product Product Unit Ordered
ID Date ID Name Address ID Description Finish Price Qty
Product Product
Product ID Unit Price
Description Finish
Ordered
Order ID Product ID
Quantity
Third Normal Form (3NF)
vA relation should be in 2NF
vAny transitive dependencies have been removed
Transitive dependency – a functional dependency between the primary key and one or more nonkey attributes that
are dependent on the primary key via another nonkey attribute
This means if we have a primary key A and a non-key domain B and C where C is more dependent on B than A and B
is directly dependent on A, then C can be considered transitively dependant on A.
DECOMPOSE relation R
A B C D E
R1(A, C)
partial FD partial FD
R2(A, B)
R3(B, E)
AC is the candidate key
R4(C, D)
example 2
Product Product
Product ID Unit Price
Description Finish
Ordered
Order ID Product ID
Quantity
Third Normal Form
• 2NF PLUS No transitive dependencies
Product Ordered
Order ID
ID Quantity
Dependency Diagram
Full Dependency
Transitive Dependencies
Order Order Cust Customer Customer Prod Product Product Unit Ordered
ID Date ID Name Address ID Description Finish Price Qty
With redundant data, when we want to change the value of one columns of a particular Dentist, for example the dentistName,
we must update all the Dentist records that assigned to the particular patient otherwise the database will become inconsistent.
We also need to modify the appointment schedules because different Dentist has different schedules.
(b) Describe and illustrate the process of normalizing the table shown in Figure 1 to 3NF. State any assumptions you make
about the data shown in this table.
Assumptions made include that a patient is registered at only one surgery and he/she may have more than one appointment on
a given day. All the schedules have been fixed for the whole days and week.
In the 1NF we remove all the repeating groups (appointment), assigning new column (apptDate and apptTime) and assigned
primary keys (candidate keys). Then we figure out the functional dependencies (FDs). By using dependency diagram we
represent the table as shown below. (NF – stand for Normal Form)
Note: How to find the FDs is subjective!!! However, the rule is, it must reflect the real word situation.
staffNo apptDate apptTime dentistName patientNo patientName surgeryNo
FD1 is already in 2NF. In this case, we can see that FD2 (just depend on staffNo) and FD4 (just depend on staffNo and apptDate)
violate the 2NF. These two NFs are partially dependent on the candidate keys not the whole keys. FD2 can stand on its own by
depending on the staffNo and meanwhile FD4 also can stand on its own by depending on the staffNo.
The FD3 violates the 3NF showing the transitive dependency where surgeryNo and patientName depend on patientNo while
patientNo depend on the staffNo that is the non-key is depending on another non-key.
staffNo apptDate apptTime dentistName patientNo patientName surgeryNo
staffNo dentistName
The 2NF, it is already in 1NF and there is no partial dependency. So we need to remove the FD2 and FD4 by splitting into
new tables and at the same time creating foreign keys.
staffNo apptDate apptTime dentistName patientNo patientName surgeryNo
FK
FK
staffNo apptDate surgeryNo
staffNo dentistName
patientNo patientName
Finally in 3NF we must remove the transitive dependency. In this case we remove the FD3 by splitting into a new table.
The transitive dependency left is the patientName that depend on the patientNo, so we split this into new table while
creating a foreign key.
staffNo dentistName
Dentist(staffNo, dentistName)
FK
staffNo apptDate surgeryNo
patientNo patientName
Patient(patientNo, patientName)
FK
staffNo apptDate apptTime patientNo
https://www.javaguicodexample.com/normalizationexercisean
swer.pdf