Home | Previous Page | Next Page   Appendix A. The stores_demo Database > Primary-Foreign Key Relationships >

The customer and orders Tables

The customer table contains a customer_num column that holds a number that identifies a customer and columns for the customer name, company, address, and telephone number. For example, the row with information about Anthony Higgins contains the number 104 in the customer_num column. The orders table also contains a customer_num column that stores the number of the customer who placed a particular order. In the orders table, the customer_num column is a foreign key that references the customer_num column in the customer table. Figure 7 shows this relationship.

Figure 7. Tables That the customer_num Column Joins
  begin figure description -- This figure shows data from portions of rows in the customer table and in the orders table, where the customer_num column in the orders table is a foreign key that references the customer_num column in the customer table. One row of the customer table shows that the name of the customer whose customer_num has the value 104 is Anthony Higgins. Two rows of the orders table show order_num and order_date values for the customer whose customer_num has the value 104. -- end figure description

According to Figure 7, customer 104 (Anthony Higgins) has placed two orders, as his customer number appears in two rows of the orders table. Because the customer number is a foreign key in the orders table, you can retrieve Anthony Higgins's name, address, and information about his orders at the same time.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]