Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Andrew Yee. Why 4NF? Performance – We want database to take up less space.

Similar presentations


Presentation on theme: "By Andrew Yee. Why 4NF? Performance – We want database to take up less space."— Presentation transcript:

1 by Andrew Yee

2 Why 4NF? Performance – We want database to take up less space.

3 Why 4NF? To eliminate the possibility for data anomalies.

4 Why 4NF? To reduce the need for: – inserts, – updates – deletes

5 Normal Forms Comparison Normal 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)

6 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. Normal Form #Key Differences 4NF An entity is in Fourth Normal Form (4NF) when it meets the requirement of being in Third Normal Form (3NF) and additionally: Has no multiple sets of multi-valued dependencies. In other words, 4NF states that no entity can have more than a single one-to-many relationship within an entity if the one-to-many attributes are independent of each other. Many:many relationships are resolved independently

7 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 Normal Form #Key Differences 4NF An entity is in Fourth Normal Form (4NF) when it meets the requirement of being in Third Normal Form (3NF) and additionally: Has no multiple sets of multi-valued dependencies. In other words, 4NF states that no entity can have more than a single one-to-many relationship within an entity if the one-to-many attributes are independent of each other. Many:many relationships are resolved independently

8 Recap of 4NF Definition No Duplications Table must be in BCNF Normal Form #Key Differences 4NF An entity is in Fourth Normal Form (4NF) when it meets the requirement of being in Third Normal Form (3NF) and additionally: Has no multiple sets of multi-valued dependencies. In other words, 4NF states that no entity can have more than a single one-to-many relationship within an entity if the one-to-many attributes are independent of each other. Many:many relationships are resolved independently

9 Example to get 4NF Assume the table is in BCNF The town, Region, and District together form the candidate key. Junk FoodCholesterol Fried Apple0 8 Asian Fries20 Asian Fries8 Quad Meat Burger0 20 From Reference #1

10 Example to get 4NF Decomposed into two tables Junk FoodCholesterol Fried Apple0 8 Asian Fries20 Asian Fries8 Quad Meat Burger0 20 From Reference #1

11 Example 2: Is it in 3NF or BCNF? RestaurantPizza VarietyDelivery Area A1 PizzaThick CrustSpringfield A1 PizzaThick CrustShelbyville A1 PizzaThick CrustCapital City A1 PizzaStuffed CrustSpringfield A1 PizzaStuffed CrustShelbyville A1 PizzaStuffed CrustCapital City Elite PizzaThin CrustCapital City Elite PizzaStuffed CrustCapital City Vincenzo's PizzaThick CrustSpringfield Vincenzo's PizzaThick CrustShelbyville Vincenzo's PizzaThin CrustSpringfield Vincenzo's PizzaThin CrustShelbyville Pizza Delivery From Reference #2

12 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

13 Example 2: Is it in 4NF? RestaurantPizza VarietyDelivery Area A1 PizzaThick CrustSpringfield A1 PizzaThick CrustShelbyville A1 PizzaThick CrustCapital City A1 PizzaStuffed CrustSpringfield A1 PizzaStuffed CrustShelbyville A1 PizzaStuffed CrustCapital City Elite PizzaThin CrustCapital City Elite PizzaStuffed CrustCapital City Vincenzo's PizzaThick CrustSpringfield Vincenzo's PizzaThick CrustShelbyville Vincenzo's PizzaThin CrustSpringfield Vincenzo's PizzaThin CrustShelbyville Pizza Delivery From Reference #2

14 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

15 Why not in 4NF? RestaurantPizza VarietyDelivery Area A1 PizzaThick CrustSpringfield A1 PizzaThick CrustShelbyville A1 PizzaThick CrustCapital City A1 PizzaStuffed CrustSpringfield A1 PizzaStuffed CrustShelbyville A1 PizzaStuffed CrustCapital City Elite PizzaThin CrustCapital City Elite PizzaStuffed CrustCapital City Vincenzo's PizzaThick CrustSpringfield Vincenzo's PizzaThick CrustShelbyville Vincenzo's PizzaThin CrustSpringfield Vincenzo's PizzaThin CrustShelbyville Pizza Delivery From Reference #2 Two Non- trivial: MVD

16 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

17 How to “fix it” (4NF)? RestaurantPizza VarietyDelivery Area A1 PizzaThick CrustSpringfield A1 PizzaThick CrustShelbyville A1 PizzaThick CrustCapital City A1 PizzaStuffed CrustSpringfield A1 PizzaStuffed CrustShelbyville A1 PizzaStuffed CrustCapital City Elite PizzaThin CrustCapital City Elite PizzaStuffed CrustCapital City Vincenzo's PizzaThick CrustSpringfield Vincenzo's PizzaThick CrustShelbyville Vincenzo's PizzaThin CrustSpringfield Vincenzo's PizzaThin CrustShelbyville Pizza Delivery From Reference #2 Two Non- trivial: MVD

18 How to “fix it” (4NF)? From Reference #2 RestaurantPizza Variety A1 PizzaThick Crust A1 PizzaStuffed Crust Elite PizzaThin Crust Elite PizzaStuffed Crust Vincenzo's Pizza Thick Crust Vincenzo's Pizza Thin Crust RestaurantDelivery Area A1 PizzaSpringfield A1 PizzaShelbyville A1 PizzaCapital City Elite PizzaCapital City Vincenzo's PizzaSpringfield Vincenzo's PizzaShelbyville Varieties By Restaurant Delivery Areas By Restaurant No Duplications among rows! Yay!

19 Practice Example 1.Is this 3NF or BCNF? 2.Is this 4NF? 3.If not, what are the decomposed tables in 4NF? RestaurantPizza VarietyDelivery Area A1 PizzaThick CrustSpringfield A1 PizzaThick CrustShelbyville A1 PizzaThick CrustCapital City A2 PizzaStuffed CrustSpringfield A2 PizzaStuffed CrustShelbyville Pizza Delivery

20 Practice Example (Answer) 1.BCNF 2. NO 3. See Below RestaurantPizza Variety A1 PizzaThick Crust A1 PizzaStuffed Crust A2 PizzaStuffed Crust RestaurantDelivery Area A1 PizzaSpringfield A1 PizzaShelbyville A1 PizzaCapital City A2 PizzaSpringfield A2 PizzaShelbyville Varieties By Restaurant Delivery Areas By Restaurant No Duplications among rows! Yay!

21 References 1.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/http://blog.todmeansfox.com/2007/12/04/database-design-4th-and-5th-normal- forms/ 2.Website: Fourth normal form - Wikipedia, the free encyclopedia URL: http://en.wikipedia.org/wiki/Fourth_normal_formhttp://en.wikipedia.org/wiki/Fourth_normal_form


Download ppt "By Andrew Yee. Why 4NF? Performance – We want database to take up less space."

Similar presentations


Ads by Google