Download presentation
Presentation is loading. Please wait.
1
Normalization – Part II
Chapter 14 Normalization – Part II Pearson Education © 2009
2
The Process of Normalization
Normalization is a formal technique for analyzing relations based on their primary key (or candidate key) and functional dependencies. Normalization executed as a series of steps. As normalization proceeds, the relations become progressively: more restricted (stronger) in format less vulnerable to update anomalies Pearson Education © 2009
3
The Process of Normalization
Normalization is performed as a series of tests on a relation to determine whether it satisfies or violates the requirements of a given normal form. For relational data model, it is important to recognize that it is only First Normal Form (1NF) that is critical in creating relations, all subsequent normal forms are optional.
4
The Process of Normalization
1NF 2NF 3NF BCNF Less vulnerable to update anomalies Stronger in format 4NF 5NF Higher Normal Form Normalization
5
The Process of Normalization
Pearson Education © 2009
6
Normalization 1 NF Better than unnormalized 2 NF Better than 1 NF 3 NF
7
Unnormalized Form (UNF)
A table that contains one or more repeating groups. To create an unnormalized table Transform the data from the information source (e.g. form) into table format with columns and rows. Pearson Education © 2009
8
Unnormalized Form (UNF)
ORDER_NUM ORDER _DATE PART_NUM DESCRIPTION NUM_ ORDERD QUOTED_ PRICE 21608 10/20/2010 AT94 Iron 11 21.95$ 21610 DR93 DW11 Gas Range Washer 1 495.00$ 399.99$ 21613 10/21/2010 KL62 Dryer 4 329.95$ 21614 KT03 Dishwasher 2 595.00$ 21617 10/23/2010 BV06 CD52 Home Gym Microwave Oven 12.95$ 150.00$ 21619 21623 KV29 Treadmill 325.99$
9
First Normal Form (1NF) A relation in which the intersection of each row and column contains one and only one value. Pearson Education © 2009
10
UNF to 1NF Nominate an attribute or group of attributes to act as the key for the unnormalized table. Identify the repeating group(s) in the unnormalized table which repeats for the key attribute(s). Pearson Education © 2009
11
UNF to 1NF Remove the repeating group by:
1- ‘flattening’ the table: Entering appropriate data into the empty columns of rows containing the repeating data. Primary key becomes the combination of primary key and redundant value. Disadvantage: introduce redundancy in the relation. Pearson Education © 2009
12
UNF to 1NF Order Order data convert to first normal form by flatting
ORDER_NUM ORDER _DATE PART_NUM DESCRIPTION NUM_ ORDERD QUOTED_ PRICE 21608 10/20/2010 AT94 Iron 11 21.95$ 21610 DR93 Gas Range 1 495.00$ DW11 Washer 399.99$ 21613 10/21/2010 KL62 Dryer 4 329.95$ 21614 KT03 Dishwasher 2 595.00$ 21617 10/23/2010 BV06 Home Gym 12.95$ CD52 Microwave Oven 150.00$ 21619 21623 KV29 Treadmill 325.99$ Order data convert to first normal form by flatting
13
UNF to 1NF Remove the repeating group by:
2- By placing the repeating data, along with a copy of the original key attribute(s), in separate relation. The Primary key for the new relation is the combination of original primary key and redundant value. Pearson Education © 2009
14
UNF to 1NF Order_Part Order Order data convert to first normal form
ORDER_NUM PART_NUM DESCRIPTION NUM_ ORDERD QUOTED_ PRICE 21608 AT94 Iron 11 21.95$ 21610 DR93 Gas Range 1 495.00$ DW11 Washer 399.99$ 21613 KL62 Dryer 4 329.95$ 21614 KT03 Dishwasher 2 595.00$ 21617 BV06 Home Gym 12.95$ CD52 Microwave Oven 150.00$ 21619 21623 KV29 Treadmill 325.99$ ORDER_NUM ORDER _DATE 21608 10/20/2010 21610 21613 10/21/2010 21614 21617 10/23/2010 21619 21623 Order data convert to first normal form by placing the repeating data, in separate relation
15
Second Normal Form (2NF)
Based on the concept of full functional dependency and composite PK. Full functional dependency indicates that if A and B are attributes of a relation, B is fully dependent on A if B is functionally dependent on A but not on any proper subset of A. Pearson Education © 2009
16
Second Normal Form (2NF)
A relation that is in 1NF and every non-primary-key attribute is fully functionally dependent on the primary key. Pearson Education © 2009
17
Second Normal Form (2NF)
ORDER_NUM ORDER _DATE PART_NUM DESCRIPTION NUM_ ORDERD QUOTED_ PRICE 21608 10/20/2010 AT94 Iron 11 21.95$ 21610 DR93 Gas Range 1 495.00$ DW11 Washer 399.99$ 21613 10/21/2010 KL62 Dryer 4 329.95$ 21614 KT03 Dishwasher 2 595.00$ 21617 10/23/2010 BV06 Home Gym 12.95$ CD52 Microwave Oven 150.00$ 21619 21623 KV29 Treadmill 325.99$ Any problem with updating Part number DR93? – Need to update 2 rows inconsistent data? Any problem if I add new row for the Part DR93, but the description is Gas Iron, or miss-spill the correct description? Deleting row? What if you delete the order #21608 what will happen for the part AT94, will get deleted as well (loss information) Insert new part number but without any order details? Can you do that? Therefore, so many problem with this tables?? We need to make it in the second normal form Is this Table in First Normal Form? (any repeating groups) Is this table in the Second Normal Form? (what is the PK)
18
Second Normal Form (2NF)
ORDERS (ORDER_NUM, ORDER_DATE, PART_NUM, DESCRPTION, NUM_ORDERED, QUOTED_PRICE) It contains the following functional dependencies: ORDER_NUMORDER_DATE PART_NUM DESCRPTION ORDER_NUM, PART_NUM NUM_ORDERED , QUOTED_PRICE , ORDER_DATE , DESCRPTION
19
1NF to 2NF Identify the primary key for the 1NF relation.
Identify the functional dependencies in the relation. If partial dependencies exist on the primary key remove them by placing them in a new relation along with a copy of their determinant. A 1NF relation with a primary key that is a single field is in 2NF automatically A relation is in second normal form (2NF) if it is in 1NF and no nonkey attribute is dependent on only a portion of the primary key or … All nonkey attributes are functionally dependent on the entire primary key Pearson Education © 2009
20
1NF to 2NF If partial dependencies exist on the primary key remove them by placing them in a new relation along with a copy of their determinant. ( ORDER_NUM, (PART_NUM, (ORDER_NUM, PART_NUM, How to complete the above relations??
21
Second Normal Form (2NF)
( ORDER_NUM, ORDER_DATE) (PART_NUM, DESCRIPTION) (ORDER_NUM, PART_NUM, NUM_ORDERED, QUOTED_PRICE)
22
1NF to 2NF ORDER_NUM ORDER _DATE PART_NUM DESCRIPTION NUM_ ORDERD
QUOTED_ PRICE 21608 10/20/2010 AT94 Iron 11 21.95$ 21610 DR93 Gas Range 1 495.00$ DW11 Washer 399.99$ 21613 10/21/2010 KL62 Dryer 4 329.95$ 21614 KT03 Dishwasher 2 595.00$ 21617 10/23/2010 BV06 Home Gym 12.95$ CD52 Microwave Oven 150.00$ 21619 21623 KV29 Treadmill 325.99$ ORDER_NUM ORDER _DATE 21608 10/20/2010 21610 21613 10/21/2010 21614 21617 10/23/2010 21619 21623 PART_NUM DESCRIPTION AT94 Iron DR93 Gas Range DW11 Washer KL62 Dryer KT03 Dishwasher BV06 Home Gym CD52 Microwave Oven KV29 Treadmill ORDER_NUM PART_NUM NUM_ ORDERD QUOTED_ PRICE 21608 AT94 11 21.95$ 21610 DR93 1 495.00$ DW11 399.99$ 21613 KL62 4 329.95$ 21614 KT03 2 595.00$ 21617 BV06 12.95$ CD52 150.00$ 21619 21623 KV29 325.99$
23
Third Normal Form (3NF) Based on the concept of transitive dependency.
Transitive Dependency is a condition where A, B and C are attributes of a relation such that if A B and B C, then C is transitively dependent on A through B. (Provided that A is not functionally dependent on B or C). Pearson Education © 2009
24
Third Normal Form (3NF) A relation that is in 1NF and 2NF and in which no non-primary-key attribute is transitively dependent on the primary key. Pearson Education © 2009
25
Third Normal Form (3NF) Is this table in Second Normal Form?
Does it have any functional dependency?
26
Third Normal Form (3NF) CUSTOMER (CUSTOMER_NUM, CUSTOMER_NAME, BALANCE, CREDIT_LIMIT, REP_NUM, LAST_NAME, FIRST_NAME) Functional dependencies: CUSTOMER_NUM CUSTOMER_NAME, BALANCE, CREDIT_LIMIT, REP_NUM, LAST_NAME, FIRST_NAME REP_NUM LAST_NAME, FIRST_NAME
27
2NF to 3NF Identify the primary key in the 2NF relation.
Identify functional dependencies in the relation. If transitive dependencies exist on the primary key remove them by placing them in a new relation along with a copy of their dominant. The Primary key for the new relation is the determinant. Pearson Education © 2009
28
Third Normal Form (continued)
29
Third Normal Form (3NF) CUSTOMER (CUSTOMER_NUM, CUSTOMER_NAME, BALANCE, CREDIT_LIMIT, REP_NUM) REP (REP_NUM, LAST_NAME, FIRST_NAME)
30
Review of Decompositions
1NF Order (Approach 1) Customer 2NF Order_date Part Order Customer 3NF Order_date Part Order Customer Rep
31
Example: DreamHome Collection of simplified DreamHome leases
32
Example: DreamHome Unnormalized table (UNF)
Which is considered the key attribute? What are the repeating group of keys?
33
Example: DreamHome UNF to 1NF
34
Example: DreamHome Alternative 1NF relations
35
Example: DreamHome Functional dependencies of the 1NF
36
Example: DreamHome Functional dependencies of the 1NF
37
Example: DreamHome 1NF to 2NF
38
Example: DreamHome 2NF to 3NF
39
Example: DreamHome 2NF to 3NF
40
Example: DreamHome Summary of the 3NF
41
Example: DreamHome Decomposition from 1NF into 3NF
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.