orderid
productid
PK
PK
orderdate
qty
customerid
companyname
FIGuRE 1-1
Data model before applying 2NF.
The second normal form is violated in Figure 1-1 because there are non-key attributes that de-
pend on only part of a candidate key (the primary key, in this example). For example, you can find
the order date of an order, as well as customerid and companyname, based on the orderid alone. To
conform to the second normal form, you would need to split your original relation into two relations:
Orders and OrderDetails (as shown in Figure 1-2). The Orders relation would include the attributes
orderid, orderdate, customerid, and companyname, with the primary key defined on orderid. The
OrderDetails relation would include the attributes orderid, productid, and qty, with the primary key
defined on orderid and productid.
Orders
Do'stlaringiz bilan baham: |