You are on page 1of 23

Normalization

CIS 2010
Not Normalized (0NF)

 Repeating groups result in data


redundancy, which can lead to loss of data
integrity as a result of update anomaly,
deletion anomaly, and insertion anomaly.
Solution: put database in first normal form
(1NF) by eliminating all repeating groups.
Not Normalized (0NF)

DiveSite Operator

DiveSite Operator Name


Depth Fax
DegreeOfDiff Phone
Temp City
NumOfWrecks
PriceRange
OperatorNames
Contacts
 Multiple operators can be present at one dive site.
 Values of the primary key field (DiveSite) are not
unique, but all field values are atomic (have only
one value). As a result, there is a lot of
redundant data, which will lead to update
anomaly, deletion anomaly, and insertion
anomaly. In a relational database, all primary
key values in a table must be unique. Because
primary key values below are not unique, these
data cannot be part of a relational database.
Here the primary key values are
not unique
DiveSite (PK) Depth DegreeOfDiff Temp NumOfWrecks OperatorNames

Belize 77 Intermediate 65 3 Clive Jones & Co.

Belize 77 Intermediate 65 3 Smith Diving

Belize 77 Intermediate 65 3 Belize Diving Co.

Great Barrier Reef 50 Intermediate 62 9 Adventures Down


Under
Key West 35 Beginner 70 11 Key West Diving

Key West 35 Beginner 70 11 Southern Diving


Here all primary key values are unique, but all field values are not atomic. Field
values must be atomic in a relational database. What would happen when you try
to delete “Smith Diving”?

DiveSite Depth DegreeOfDiff Temp NumOfWrecks OperatorNames

Belize 77 Intermediate 65 3 Clive Jones & Co.,


Smith Diving,
Belize Diving Co.

Great Barrier Reef 50 Intermediate 62 9 Adventures Down


Under

Key West 35 Beginner 70 11 Key West Diving,


Southern Diving
Deleting “Smith Diving” takes out the
fact that Clive Jones and Belize diving
were operating in Belize!

DiveSite Depth DegreeOfDiff Temp NumOfWrecks OperatorNames

Great Barrier Reef 50 Intermediate 62 9 Adventures Down


Under

Key West 35 Beginner 70 11 Key West Diving,


Southern Diving
First Normal Form (1NF)
 A table that is in First Normal Form has no
repeating groups. (No further
normalization is required for a relational
database.)
DivePackage
DiveSite Operator
DiveSite
DiveSite OperatorName OperatorName
Depth Fax DivePackage
DegreeOfDiff Phone Contact
Price
Temp City
Tax
NumOfWrecks PriceRange Total
Repeating Groups in other
Contexts
 Order Table
 OrderNumber
 Date
 Time
 Location
 Clerk
 Items
• Item #1
• Item #2
• Item #3
• …
Examples of Repeating Groups
 Auto service (a customer may bring the car in many
times)
 Hotel (a customer may have many hotel stays)
 Cell phone store (a customer may purchase multiple
phones and/or other devices)
 Cell phone bills (calls are repeating groups)
 Order for delivery (customer name entered once,
multiple orders per customer, multiple items per order)
 Blockbuster video (multiple visits, multiple rentals and
snacks purchased on each visit)
 Booking a flight (customer has one record at Expedia,
but a customer may have many flights, many hotel stays,
many car rentals booked)
Examples of Repeating Groups
 Items purchased with an order
 Courses in which a student enrolls this semester
 Books borrowed from the library
 Stocks in a customer’s portfolio
 Dialed calls on a phone bill
 Photos uploaded to Walgreen’s photo website to be
printed
 Jobs a person has had (in an organization)
 For commission-based people, transactions on which the
salesperson will earn a commission
 Placing an order to replenish inventory to a specific
supplier
 Number of dependents associated with a taxpayer
What data would you put in a
Patient Table?
SS#
FName
LName
First Draft of Patient Table
SS# (primary key) Date of last visit
FName Reason for visit
LName Patient history
MI Emergency contact
Street EC phone
City EC relationship to patient
State DOB
Zip Driver’s license #
Telephone # Gender
Cell phone #
E-mail address
Insurance provider
Problems with First Draft of Patient
Table
 A patient may have more than one insurance provider
(through own employer and spouse’s employer or
through Medicare and the former employer, for
example).
 Most patients will visit the office more than once. The
doctor can’t just replace the value in the ‘Date of last
visit’ field, because an insurance company, lawyer, or
even the state medical licensing board may have
questions about various previous visits.
 The patient’s medical history may belong in a separate
table that only the doctor(s) and nurse(s) can access--
not the staff involved with scheduling and billing. Also,
the patient history may involve multiple fields.
New Database Design (without repeating groups)
Patient Visit Table
Patient Table SS#
SS# (primary key) Date of Visit
FName Reason for visit
LName …
MI Diagnosis
Street Notes
City
State Patient Insurance table
Zip SS#
Telephone # Provider Name
Cell phone # Provider Address
E-mail address Provider Phone
Emergency contact Plan
EC phone Account #
EC relationship to patient …
DOB
Driver’s license # Patient History Table
Gender SS#
Cancer in family? (Y/N)
Cancer notes
Heart disease in family? (Y/N)
Heard disease notes
Allergies (Memo field?)

Second Normal Form (2NF)
 Each table is in 1NF, and no non-key
attribute or field is functionally dependent
on just a part of a compound or
concatenated primary key (a primary key
that has more than one field).
DivePackage
OperatorContact
DiveSite
OperatorName OperatorName
DivePackage Contact
Price Notes
Tax
Total
Fields Not Part of Primary Key
Third Normal Form (3NF)
 A table is in 3NF if it is in 1NF and 2NF,
and no non-key attribute or field can be
derived from another non-key attribute.
DivePackage
DiveSite
OperatorName
DivePackage
Price
Tax

You might also like