Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The functional dependencies in this tale are as follows: CustomerNum > CustomerNAme, Balance, CreditLimit, RepNum, LastName, FirstName RepNum > LastName, FirstName
When the primary key of a table is a single column, the table is automatically in second
C C Num Name
148 282 356 408 524 608
Als
Appliance
$7500
$10000
20 35 65 35 20 65
and Sport
Brookings
Direct
Fergusons
$7500
Store
687
Appliance
$2851
$5000
35
Hull
Richar d
725
Deerfields
Seasons
Four
$248
$7500
35
Hull
Richar d
842
All Season
This redundancy creates the same set of problems that you examined in the first normal form Orders table. In addition to the problem of wasted space, you have similar update anomalies as follows:
1.
2. Inconsistent data. There is nothing about the design that would prohibit a sales rep from having two different names in the database. In fact, if the same sales rep represents 20 customers, he or she could have 20 different names in the database.
3. Additions In order to add sales rep 87 (Mary Daniels) to the database, she must already represent at least one customer. IF she has not yet been assigned any customers, you must add her record and create a fictitious customer for her to represent. Again, this is not a desirable solution to the problem.
These update anomalies are due to the fact that RepNum determines LastName and FirstName, but RepNum is not the primary key. As a result, the same RepNum and consequently the same LastName and FirstName can appear on many different rows.
Definition: Any column that determines another column is called a determinant. Definition: A table is in third normal form (3NF) when it is in second normal form and the only determinants it contains are candidate keys.
For each determinant that is not a candidate key, remove from the table the columns that depend on this determinant.
Customer Num 148 282 356 408 462 524 608 687 725
CustomerName
Als Appliance and Sport Brookings Direct Fergusons The Everything Shop Bargains Galore Klines Johnsons Department Store Lees Sport and Appliance Deerfields Four Seasons
RepNum LastName
20 35 65 Kaiser Hull Perez
FirstName
Valerie Richard Juan
Incorrect Decompositions It is important to note that the decomposition of a table into two or more third normal form tables must be accomplished by the method indicated in the previous section, even though there are other possibilities that at first glance might seem to be legitimate.
Customer ( CustomerNum, CustomerName, Balance, CreditLimit, RepNum, LastName, FirstName) is replaced by Customer ( CustomerNum, CustomerName, Balance, CreditLimit, RepNum) Rep (CustomerNum, LastName, FirstName)
Customer Num 148 282 356 408 462 524 608 687 725
CustomerName
Als Appliance and Sport Brookings Direct Fergusons The Everything Shop Bargains Galore Klines Johnsons Department Store Lees Sport and Appliance Deerfields Four Seasons
462 524
608 687 725 842
Perez Kaiser
Perez Hull Hull Kaiser
Juan Valerie
Juan Richard Richard Valerie
Consider, for example, the redundancy in the storage of sales reps names, the problem encountered in changing the name
represents no customers.
In addition, because the rep number and names are in different tables, you have actually split a functional dependence across two different tables. Thus, this seemingly valid decomposition is definitely not a desirable way to create third normal form tables.
CustomerName, Balance,
CreditLimit, LastName, FirstName)
CustomerN um
CustomerName
Als Appliance and Sport Brookings Direct Fergusons
Balan CreditLim it ce
$6550.00 $431.40 $5785.00 $7500.00 $10000.00 $7500.00
LN
Kaiser Hull Perez
FN
Valeri e Richar d Juan
408
462 524 608 687 725
$5825.25
$3412.00 $12762.00 $2106.00 $2851.00 $248.00
$5000.00
$10000.00 $15000.00 $10000.00 $5000.00 $7500.00
Hull
Perez Kaiser Perez Hull Hull
Richar d
Juan Valeri e Juan Richar d Richar d
RepNum LastName
20 35 65 Kaiser Hull Perez
FirstName
Valerie Richard Juan