table of the first normalized form
voucherNo | date | Customer Code | Customer Name | Address | City Code | PhoneNo |
---|---|---|---|---|---|---|
0129 | 2004/08/10 | 001 | hoo Commercial company | Yokohama | 012 | 045**** |
0157 | 2004/08/13 | 103 | Boo Real Estate | Kawasaki | 033 | 044**** |
0248 | 2004/08/22 | 056 | foo Industry | Fujisawa | 056 | 047**** |
voucherNo | goodscode | unit | quantity | unit price |
---|---|---|---|---|
0129 | Z101 | cm | 200 | 1000 |
0129 | N029 | gallon | 50 | 3000 |
0157 | K403 | kg | 40 | 2000 |
0248 | N029 | gallon | 300 | 1000 |
0248 | T110 | dl | 120 | 9400 |
0248 | Q200 | l | 870 | 750 |
Although the first normalized form removes the limit on the number of sales at a time, this still results in wasted space. For example, if a hoo Commercial company purchases 3 days in a row, there will be duplicates in one table, even though the Customer Code, Customer Name, and Address are the same data. The same is true if there are hit GOODS and a large number of the same GOODS are purchased. Such a situation is wasteful and should be eliminated, no matter how large the disk capacity has become. Furthermore, the update process is wasteful because it requires updating data in multiple locations.
So let's take another step from first normal form to second normal form.
The Customer Code is different for each customer, so you know the Customer Name and Address from the Customer Code. In other words, they are function dependent. Among function dependencies, those that are function dependent on items other than the primary key are called partial function dependencies.
Eliminating this partial function dependence of Table in the first normal form yields the second normal form. The elimination of partial function dependencies is done by splitting the table. In the same way, unit and unit price, which are partially dependent on goodscode, are also divided, resulting in the following table structure.
Tables in second normal form
Orders table
voucherNo | date | Customer Code |
---|---|---|
0129 | 2004/08/10 | 001 |
0157 | 2004/08/13 | 103 |
0248 | 2004/08/22 | 056 |
Customer Code | Customer Name | Address | City Code | PhoneNo |
---|---|---|---|---|
001 | hoo Commercial company | Yokohama | 012 | 045**** |
103 | Boo Real Estate | Kawasaki | 033 | 044**** |
056 | foo Industry | Fujisawa | 056 | 047**** |
voucherNo | goodscode | quantity |
---|---|---|
0129 | Z101 | 200 |
0129 | N029 | 50 |
0157 | K403 | 40 |
0248 | N029 | 300 |
0248 | T110 | 120 |
0248 | Q200 | 870 |
goodscode | unit | unit price |
---|---|---|
Z101 | cm | 1000 |
N029 | gallon | 3000 |
K403 | kg | 2000 |
T110 | dl | 9400 |
Q200 | l | 750 |
This saves disk space. The update can be localized (e.g., only one record is needed to update the unit price of N029). (For example, updating the unit price of N029 requires only one record.) The key entry in each table is the one to which the function is subordinated.