Professional Documents
Culture Documents
Normalization
Normal Form Overview
Universe of All Data
Relations (normalized / unnormalized
1st Normal Form
2nd Normal Form
3rd Normal Form
Boyce-Codd Normal Form (BCNF)
4th Normal Form
5th Normal Form (PJ/NF)
Domain/Key
Normal Form
(DK/NF)
Example 1 - suppliers:
part suppliers
diode (GE, TRW, Mot)
bulb (GE, Syl)
Implemented as:
part supplier1 supplier2 supplier3
diode GE TRW Mot
bulb GE Syl
Retrieval:
• which supplier of a part should be
retrieved?
• in which order should suppliers be
retrieved?
Storage:
• how many suppliers do you allow for?
• which spaces are kept blank, and how?
Insert:
• to add a supplier, need to retrieve all
suppliers, add the new supplier to an empty
slot, and replace the record
Delete:
• to delete a supplier, need to “adjust” the
vector (read, move around, erase, re-write)
Update:
• to update a supplier name, need to retrieve
all suppliers, find the one to alter, and re-
write entire set of suppliers
Example 1 - suppliers:
part supplier
diode GE
diode TRW
diode Mot
bulb GE
bulb Syl
Example 2 - inventory:
part # warehouse # wh_address quantity
100 05 Mpls 200
100 08 StPaul 300
200 05 Mpls 250
200 10 Madison 400
300 08 StPaul 350
Update Anomalies:
UPDATE
• address of warehouse stored in many rows
• if address changes, must change all rows
DELETE
• if the last row for a warehouse is deleted, the address is
lost
INSERT
• to insert a new row, warehouse address must be known
Example 2 - inventory:
One table about warehouses:
warehouse# wh_address
05 Mpls
08 StPaul
10 Madison
Example 3 - departments:
name dept dept_loc
smith 402 100
jones 401 200
king 402 100
turner 400 200
olson 401 200
Update Anomalies:
OR
OR
Example 4 - locations:
dept# dept_name dept_loc
400 programming 200
401 financial 200
402 academic 100
403 support 300
Example 5 - stock:
s# sname p# qty
10 GE 102 1000
10 GE 103 625
10 GE 104 2000
20 TRW 102 500
20 TRW 105 1200
30 Syl 103 1300
• technically in 3NF
• qty is the only non-key attribute (like example 1)
• candidate keys are (s#, p#) and (sname, p#)
• didn't require components of an alternate key to be fully
functionally dependent on the primary key
Example 6 - enrollment
Rules:
1. For each subject, each student is taught by 1 teacher
2. Each teacher teaches only 1 subject (don't I wish)
3. Each subject is taught by several teachers
Example 7 - skills:
Suppose we wish to store employee job skills and
language skills. (An employee may have many of each.)
employee skill language
Jones electrical French
Jones electrical German
Jones mechanical French
Jones mechanical German
Smith plumbing Spanish
In general: if Jones x A
and Jones y B
then Jones x B
and Jones y A
Example 8 - dealerships:
1. Agents represent Companies
2. Companies make Products
3. Agents sell Products
BREAK INTO 3
No insertion/deletion anomalies
Constraint types:
• domain constraints
• key constraints
Example 9 - customers
cust# branch
1234 west
1325 south
1421 east
1511 south
Blueprints contain:
• parts at locations
• wired connections
• attributes for each wire and location
Objectives:
• number of wires from any source to any destination
• sub-classified by voltage, shielding, and intrinsic
safety characteristics
• obtain conduit count from wire count (by hand)
Wire 53 Wire
Part:
Panel (3) AS
405
Panel (4)
Problem:
Count the wires going from panel (3) to
panel (4)
Population:
• MBA students
• MIS majors
• last quarter in the program
Language:
• Nomad 2 4GL
Case:
• Customer, with attributes
• Dealer, with attributes
• Manufacturer, with attributes
• Contracts - customer, dealer, manufacturer, with
symmetry constraints
Task:
• Given case description fully analyzed
• Use existing Nomad database
• Perform 8 queries
• Perform 11 updates
Design:
• 3 groups of 14 students
• same case, same queries, same updates
• different schemas (1NF, 3NF, and 5NF)
1NF Schema:
(d#, m#, c#, mfgr_attr, cust_attr, dealer_attr)
3NF Schema:
(c#, cust_attr)
(d#, dealer_attr)
(m#, mfgr_attr)
(d#, c#, m#)
5NF Schema:
(c#, cust_attr)
(d#, dealer_attr)
(m#, mfgr_attr)
(d#, c#)
(d#, m#)
(c#, m#)
Possible solutions:
1. Don't normalize
2. Don't normalize beyond BCNF
3. Normalize to 5NF, but back off
Problems with 1-3: update anomalies, bad data,
knowledge of database storage needed
4. Don't let users at base tables
5. Create views that are in low normal forms
6. Pre-define joins that give users the data they need
Solutions 4-6 are more work, but generally worth the
effort