Understanding Table Relationships

Team-Fly    

 
10 Minute Guide to Microsoft Access 2002
By Joe Habraken
Table of Contents
Lesson 11.  Creating Relationships Between Tables

Understanding Table Relationships

You've already learned in Lesson 2, "Working in Access," that the best way to design a database is to create tables that hold discrete types of information. For example, one table can contain customer information, and another table can hold order information. By creating relationships between tables, you enable forms, queries, and reports to combine information from the tables to produce meaningful results.

Suppose that you have two tables in your database. One table, Customers, contains names and addresses; the other, Orders, contains orders the customers have placed. The two tables both contain a common field: Customer ID. All records in the Orders table correspond to a record in the Customers table. (This is called a one-to-many relationship because one customer could have many orders.)

The secret to creating relationships revolves around the primary keys for your tables. For example, in a Customers table, the primary key is the Customer ID. It uniquely identifies each customer record. Then, when you design an Orders table, you make sure that you include the Customer ID field. In the Orders table, the Customer ID is not the primary key (it is actually called the foreign key); a field such as Order Number would be the primary key field. You include the Customer ID field in the Orders table so that order information can be linked to customer information in the Customers table.

Plain English

Foreign Key A primary key field in a table that is duplicated in a second table (where it is not theprimary key) and used link the tables together .



Team-Fly    
Top
 


10 Minute Guide to Microsoft Access 2002
10 Minute Guide to Microsoft Access 2002
ISBN: 0789726319
EAN: 2147483647
Year: 2000
Pages: 160
Authors: Joe Habraken

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net