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 is described in the surrounding text. - 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 ]