Upload
moses-reynolds
View
217
Download
3
Tags:
Embed Size (px)
Citation preview
Normal Forms ComparisonNormal Form # What you need?
1NF Remove repeating Groups
2NF Remove Partial Dependencies
3NF Remove Transitive Dependencies
BCNF Make sure every determinant is a Candidate Key
4NF Remove nontrivial Multi-Valued Dependencies (MVD)
Non-Trival Multi-Valued Dependencies (MVD)
• Assume X is the Superkey–“Superkey” still depends on FD’s only.
• Y is not a subset of X• X and Y are not, together, all the
attributes.
Recap of 4NF Definition
• No non-trivial multi-valued dependencies- Except on superset of a candidate key- Multi-valued dependencies are functional
dependencies.
• Table must be in BCNF
Example to get 4NF
• Assume the table is in BCNF• The town, Region, and District together form the candidate
key.
From Reference #1
Example 2: Is it in 3NF or BCNF?Restaurant Pizza Variety Delivery Area
A1 Pizza Thick Crust Springfield
A1 Pizza Thick Crust Shelbyville
A1 Pizza Thick Crust Capital City
A1 Pizza Stuffed Crust Springfield
A1 Pizza Stuffed Crust Shelbyville
A1 Pizza Stuffed Crust Capital City
Elite Pizza Thin Crust Capital City
Elite Pizza Stuffed Crust Capital City
Vincenzo's Pizza Thick Crust Springfield
Vincenzo's Pizza Thick Crust Shelbyville
Vincenzo's Pizza Thin Crust Springfield
Vincenzo's Pizza Thin Crust Shelbyville
Pizza Delivery
From Reference #2
Example 2: Is it in 3NF or BCNF?
• The table has no non-key attributes because its only key is {Restaurant, Pizza Variety, Delivery Area}.
• The answer is BCNF.
From Reference #2
Example 2: Is it in 4NF?Restaurant Pizza Variety Delivery Area
A1 Pizza Thick Crust Springfield
A1 Pizza Thick Crust Shelbyville
A1 Pizza Thick Crust Capital City
A1 Pizza Stuffed Crust Springfield
A1 Pizza Stuffed Crust Shelbyville
A1 Pizza Stuffed Crust Capital City
Elite Pizza Thin Crust Capital City
Elite Pizza Stuffed Crust Capital City
Vincenzo's Pizza Thick Crust Springfield
Vincenzo's Pizza Thick Crust Shelbyville
Vincenzo's Pizza Thin Crust Springfield
Vincenzo's Pizza Thin Crust Shelbyville
Pizza Delivery
From Reference #2
Example 2: Is it in 4NF?
• If we assume, that pizza varieties offered by a restaurant are not affected by delivery area, then it does not meet 4NF.
• The answer is NO.
From Reference #2
Why not in 4NF?Restaurant Pizza Variety Delivery Area
A1 Pizza Thick Crust Springfield
A1 Pizza Thick Crust Shelbyville
A1 Pizza Thick Crust Capital City
A1 Pizza Stuffed Crust Springfield
A1 Pizza Stuffed Crust Shelbyville
A1 Pizza Stuffed Crust Capital City
Elite Pizza Thin Crust Capital City
Elite Pizza Stuffed Crust Capital City
Vincenzo's Pizza Thick Crust Springfield
Vincenzo's Pizza Thick Crust Shelbyville
Vincenzo's Pizza Thin Crust Springfield
Vincenzo's Pizza Thin Crust Shelbyville
Pizza Delivery
From Reference #2
Two Non-trivial: MVD
Why not in 4NF?
• The table has two non-trivial multivalued dependencies on the {Restaurant} attribute (which is not a superkey).
• The dependencies are:– {Restaurant} →→ {Pizza Variety}– {Restaurant} →→ {Delivery Area}
From Reference #2
How to “fix it” (4NF)?Restaurant Pizza Variety Delivery Area
A1 Pizza Thick Crust Springfield
A1 Pizza Thick Crust Shelbyville
A1 Pizza Thick Crust Capital City
A1 Pizza Stuffed Crust Springfield
A1 Pizza Stuffed Crust Shelbyville
A1 Pizza Stuffed Crust Capital City
Elite Pizza Thin Crust Capital City
Elite Pizza Stuffed Crust Capital City
Vincenzo's Pizza Thick Crust Springfield
Vincenzo's Pizza Thick Crust Shelbyville
Vincenzo's Pizza Thin Crust Springfield
Vincenzo's Pizza Thin Crust Shelbyville
Pizza Delivery
From Reference #2
Two Non-trivial: MVD
How to “fix it” (4NF)?
From Reference #2
Restaurant Pizza Variety
A1 Pizza Thick Crust
A1 Pizza Stuffed Crust
Elite Pizza Thin Crust
Elite Pizza Stuffed Crust
Vincenzo's Pizza Thick Crust
Vincenzo's Pizza Thin Crust
Restaurant Delivery Area
A1 Pizza Springfield
A1 Pizza Shelbyville
A1 Pizza Capital City
Elite Pizza Capital City
Vincenzo's Pizza Springfield
Vincenzo's Pizza Shelbyville
Varieties By RestaurantDelivery Areas By Restaurant
No Duplications among rows! Yay!
Practice Example1. Is this 3NF or BCNF?2. Is this 4NF? 3. If not, what are the decomposed tables in 4NF?
Restaurant Pizza Variety Delivery Area
A1 Pizza Thick Crust Springfield
A1 Pizza Thick Crust Shelbyville
A1 Pizza Thick Crust Capital City
A2 Pizza Stuffed Crust Springfield
A2 Pizza Stuffed Crust Shelbyville
Pizza Delivery
Practice Example (Answer)1. BCNF 2. NO 3. See Below
Restaurant Pizza Variety
A1 Pizza Thick Crust
A1 Pizza Stuffed Crust
A2 Pizza Stuffed Crust
Restaurant Delivery Area
A1 Pizza Springfield
A1 Pizza Shelbyville
A1 Pizza Capital City
A2 Pizza Springfield
A2 Pizza Shelbyville
Varieties By Restaurant Delivery Areas By Restaurant
No Duplications among rows! Yay!
References1. Website: Database Design: 4th and 5th Normal Forms « Tod means Fox
URL: http://blog.todmeansfox.com/2007/12/04/database-design-4th-and-5th-normal-forms/
2. Website: Fourth normal form - Wikipedia, the free encyclopediaURL: http://en.wikipedia.org/wiki/Fourth_normal_form