Datasheet
The OrderDetails table is as follows:
We now have three tables that can be linked together by their ID fields as shown in Figure 8-1:
Figure 8-1
We now have links between the tables. The
CustomerID field in the Orders table is used to identify
which customer the order is for. Similarly, the
OrderID field in the OrderDetails table identifies which
order a particular order line belongs to.
The unique key in a table is defined as its Primary Key – it's what uniquely defines a row. When used in
another table it is called the Foreign Key, so called because it's a key, but one to a foreign table. The
OrderDetailsID OrderID Order Item Quantity Item Cost
1 1 Widget 10 3.50
2 1 Doodad 5 2.95
3 2 Thingy 1 15.98
4 3 Widget 1 3.50
5 4 Doodad 2 2.95
6 4 Thingamajig 1 8.50
OrderID CustomerID OrderDate
1 1 01/07/2003
2 1 01/08/2003
3 2 01/08/2003
4 3 01/09/2003
250
Chapter 8
57084_08.qxp 30/01/2004 8:02 PM Page 250