Microsoft 9GD00001 Computer Accessories User Manual


 
Chapter 7: Working with Data 187
customer data. Notice that you need only type a name in the Name column (replacing the
word NULL) and do not need to enter a value for the CustomerID, since we’ve made the
CustomerID column auto-increment.
In a database of any sophistication, you have multiple tables. In the MyShop database,
a Customer has an Order. So, create a new table named Order, shown in Figure 7-5,
that has Primary Key OrderID, a datetime field called OrderDate, and an int field called
CustomerID.
The Description in the Column Properties for the CustomerID field says FK to
Customer. FK is an abbreviation for foreign key, which is used to create a relationship
between a parent table and a child table. The next section explains more about what
a foreign key is and how to create one.
Relating Tables with Foreign Keys
Foreign keys allow you to establish a relationship between two tables. You can think of
this relationship as being parent/child, master/detail, or one-to-many; each analogy being
equal, I’ll use parent/child. The preceding section shows how to create Customer and
Order tables. The relationship between these two tables is that Customer is the parent and
Order is the child. One record in Customer can have many records in Order; customers
Figure 7-5 The Order table