Anda di halaman 1dari 36

Order Normalization Example

Un-Normalization Form UNF

1. Based on Dr. E. Codds rules, each cell can only hold one and only one piece of information. 2. A table is a UNF (Un-normalized Form) table if some records inside the table contain multiple values (multiple pieces of information). Under such situation, we need to normalize this table and its data. There are three normalization forms to complete normalization jobs.

3.

First Normalization Form 1NF

1NF (First Normal Form)

1NF Rules:
1. The table must be UNF. 2. Highlight all of the columns that contain multiple data (in red color ). 3. Fill in blank to make sure each record contain the same number of data (in blue color)

1NF ( Continued )

1NF Rules:
4. Move the highlighted columns (in red color) to a new table.

1NF ( Continued )

1NF Rules:
5. Make a copy of one column from the original table to a new table. 6. In this case, I would like to choose order# column (all columns are related to order# column, so I choose it)

1NF ( Continued )

1NF Rules:
7. Highlight and Eliminate repeating records in each table.

1NF ( Continued )
PS: There is no repeating records for the new table.

1NF Rules:
7. Highlight and Eliminate repeating records in each table.

1NF ( Continued )

PK ORDER( order#, order_dt, cust#, c_name, st)

1NF Rules:
8. Define a Primary Key column for each table. (Based on DB rules, the Primary Key column in each table can only hold unique data) 9. Express the table definition in English (includes table name, column name, the PK)

1NF ( Continued )
PS: If you could not define a Primary Key for a single column, you can consider choosing multiple columns; which means, the combination data of multiple columns must be unique.

PK ORDER_ITEM( order#, item#, item_name, qty, Price)

1NF Rules:
8. Define a Primary Key column for each table. (Based on DB rules, the Primary Key column in each table can only hold unique data) 9. Express the table definition in English (includes table name, column name, the PK)

End of 1NF

PK ORDER( order#, order_dt, cust#, c_name, st)

PK ORDER_ITEM( order#, item#, item_name, qty, Price)

End of Second Normalization Form

Second Normalization Form 2NF

2NF (Second Normal Form)

2NF Rules:
1. The table must be 1NF. 2. Highlight all of the columns that are not fully dependent on the whole Primary Key column. or Highlight all of the columns that are partially dependent on the whole Primary Key column. PS: 2NF only handles tables with multiple columns Primary Key. A table with single column Primary key is already in the 2NF.

2NF (Continued)
PS: If a table is defined a Primary Key for a single column, this table is already in 2NF.

PK ORDER( order#, order_dt, cust#, c_name, st)

2NF Rules:
1. The table must be 1NF. 2. Highlight all of the columns that are not fully dependent on the whole Primary Key column. or Highlight all of the columns that are partially dependent on the whole Primary Key column. PS: 2NF only handles tables with multiple columns Primary Key.

2NF (Continued)

PK ORDER_ITEM( order#, item#, item_name, qty, Price)

2NF Rules:
1. The table must be 1NF. 2. Highlight all of the non-primary key columns that are not fully dependent on the whole Primary Key column (in green color). or Highlight all of the non-primary key columns that are partially dependent on the whole Primary Key column (in green color).

2NF (Continued)
PS: If a table is defined a Primary Key for multiple columns, you need to apply 2NF rules on it. 1. Check each non-primary key column to see if it is fully dependent on the whole Primary Key columns. 2. Item_name column is only dependent on item#, so you need to highlight it. 3. Qty column is fully dependent on the whole Primary Key. 4. Price column is only dependent on item#, so you need to highlight it.

2NF Rules:
1. The table must be 1NF. 2. Highlight all of the non-primary key columns that are not fully dependent on the whole Primary Key column (in green color). or Highlight all of the non-primary key columns that are partially dependent on the whole Primary Key column (in green color). PS: 2NF only handles tables with multiple columns Primary Key.

2NF (Continued)

2NF Rules:
3. Move the highlighted columns to a new table. 4. Make a copy of one column from the old table to a new table. In this case, I would like to choose itemr# column (all columns in the new table are related to item# column in the old table, so I choose it)

2NF (Continued)

2NF Rules:
3. Move the highlighted columns to a new table. 4. Make a copy of one column from the old table to a new table. In this case, I would like to choose itemr# column (all columns in the new table are related to item# column in the old table, so I choose it)

2NF (Continued)

PK ORDER_ITEM( order#, item#, qty)

2NF Rules:
5. Highlight and Eliminate repeating records in each table.

2NF (Continued)

PK ORDER_ITEM( order#, item#, qty)

2NF Rules:

PK ITEM( item#, item_name, Price)

5. Highlight and Eliminate repeating records in each table.

2NF (Continued)

PK ITEM( item#, item_name, Price)

2NF Rules:
6. Define a Primary Key column for the new table. (The Primary Key column that you are going to choose can only hold unique data) 7. Express the table definition in English (includes table name, column name, the PK)

PK ORDER_ITEM( order#, item#, qty)

PK ITEM( item#, item_name, Price)

PK ORDER( order#, order_dt, cust#, c_name, st)

End of Second Normalization Form

Third Normalization Form 3NF

3NF (Third Normal Form)

PK ORDER_ITEM( order#, item#, qty)

PK ITEM( item#, item_name, Price)

3NF Rules:
1. The table must be 2NF.

PK ORDER( order#, order_dt, cust#, c_name, st)

3NF (continued)
PS: qty is solely dependent on Primary Key column. There is no other non-primary key column for qty column to be dependent on.

3NF Rules:
2. Highlight all of the non-primary key columns that are not solely dependent on the Primary Key column. or Highlight all of the non-primary key columns that are dependent on Primary Key column and other non-primary key columns .

3NF (continued)
PS: 1. item_name non-primary key column is solely dependent on item# column. There is no other non-primary key column for item_name column to be dependent on. 2. price column non-primary key is solely dependent on item# column. There is no other non-primary key column for price column to be dependent on.

3NF Rules:
2. Highlight all of the non-primary key columns that are not solely dependent on the Primary Key column. or Highlight all of the non-primary key columns that are dependent on Primary Key column and other non-primary key columns .

3NF (continued)

PS: 1. order_dt non-primary key column is solely dependent on order# column. There is no other non-primary key column for order_dt column to be dependent on. 2. cust# non-primary key column is solely dependent on order# column. There is no other non-primary key column for cust# column to be dependent on. 3. c_name non-primary key column is dependent on order# column. C_name is also dependent on cust# non-primary key column. So, you need to highlight c_name column. 4. st non-primary key column is dependent on order# column. St non-primary key column is also dependent on cust# non-primary key column. So, you need to highlight c_name column.

3NF Rules:
2. Highlight all of the non-primary key columns that are not solely dependent on the Primary Key column. or Highlight all of the non-primary key columns that are dependent on Primary Key column and other non-primary key columns .

3NF (continued)

3NF Rules:
3. Move the highlighted columns to a new table. 4. Make a copy of one column from the original table to a new table. In this case, I would like to choose itemr# column (all columns in the new table are related to item# column in the old table, so I choose it)

3NF (continued)

PK ORDER( order#, order_dt, cust#)

3NF Rules:
5. Highlight and Eliminate repeating records in each table.

3NF (Continued)

PK CUSTOMER( cust#, c_name, st)

3NF Rules:
6. Define a Primary Key column for the new table. (The Primary Key column that you are going to choose can only hold unique data) 7. Express the table definition in English (includes table name, column name, the PK)

3NF (Continued)

PK CUSTOMER( cust#, c_name, st)

PK ORDER( order#, order_dt, cust#)

PK ORDER_ITEM( order#, item#, qty)

PK ITEM( item#, item_name, Price)

End of
Third Normalization Form

Results of Normalization

PK CUSTOMER( cust#, c_name, st)

PK ORDER( order#, order_dt, cust#)

PK ORDER_ITEM( order#, item#, qty)

PK ITEM( item#, item_name, Price)

Anda mungkin juga menyukai