SQL Strategy - A site to master SQL while executing it on the Web
Home >> Normalization strategy - From second normal form to third normal form

From second normal form to third normal form

Let's eliminate transitive functional dependencies and go to third normal form.

Tables in second normal form Orders table

voucherNodateCustomer Code
01292004/08/10001
01572004/08/13103
02482004/08/22056

customer table
Customer CodeCustomer NameAddressCity CodePhoneNo
001hoo Commercial companyYokohama012045****
103Boo Real EstateKawasaki033044****
2004/08/22foo IndustryFujisawa056047****

quantity table
voucherNogoodscodequantity
0129Z101200
0129N02950
0157K40340
0248N029300
0248T110120
0248Q200870

goods table
goodscodeunitunit price
Z101cm1000
N029gallon3000
K403kg2000
T110dl9400
Q200l750

As those with good instincts may have noticed, the PhoneNo for City is functionally subordinate to the City Code, right?

Since the PhoneNo of the City is not a candidate key in the customer table, the Table was not split in the process of making the second normal form, but once the Customer Code is determined, the City Code is determined, and once the City Code is determined, the PhoneNo is determined. Such a situation is called a transitive function dependency. To add, when A is B, B is C, and therefore A is C in the three-stage argument, C is transitive function dependent on A.

Eliminating the transitive function dependence in the second normal form results in the third normal form, so the "B is C" part is split into a separate Table. Then, the table structure is as follows.

Tables in third normal form
Orders table

voucherNodateCustomer Code
01292004/08/10001
01572004/08/13103
02482004/08/22056

customer table
Customer CodeCustomer NameAddressCity Code
001hoo Commercial companyYokohama012
103Boo Real EstateKawasaki033
2004/08/22foo IndustryFujisawa056

PhoneNo Table
City CodePhoneNo
012045****
033044****
056047****

quantity table
voucherNogoodscodequantity
0129Z101200
0129N02950
0157K40340
0248N029300
0248T110120
0248Q200870

goods table
goodscodeunitunit price
Z101cm1000
N029gallon3000
K403kg2000
T110dl9400
Q200l750

This completes the third normalized form. In many systems, normalization up to this point is sufficient for practical use. For example, if the phone number of the city hall is changed, multiple phone numbers need to be updated in the second normalized form, but once the third normalized form is completed, only one record in the phone table needs to be updated. If the customer's company name changes, it only needs to be updated in one place, and if the number of goods increases, only one record needs to be added. Such a situation is called "one fact in one place," which means that data manipulation can be done with minimal effort. It is very efficient.

A quick review of the normalization process is as follows.

・Non-normal form to first normal form
To eliminate repeating groups, divide by repeating groups and key items.

・first normalized form to second normalized form
Split function dependencies on key items other than the primary key.

・Second to third normal form
Split transitively function dependent.

These are the three steps.

Some of them may not have transitive functional dependencies. In those cases, when the second normal form is used, it is completed up to the third normal form.

Now, finally, let's solve the past questions.