Share this Page URL

Chapter 1. The HelloWorld Database > Creating a Table - Pg. 8

The HelloWorld Database 8 Quick Check Q. What are the three main parts of a field's definition in a table? A. The field name, the data type, and a description of the field. Q. What data type would you select for a part number field? A. The Text data type. Although the field stores numerical data, the data isn't used in calculations, so the Text data type is the right choice. Designating a Primary Key The last step we'll take in defining the Greetings table is to designate a primary key --the field (or fields) in a table that uniquely identifies each record in the table. Access won't let you save a record in a table if another record already has the same primary key value. Because the primary key dis- tinguishes each record in a table, you use it to relate the records in one table to records in another. As an example of a primary key, imagine a database used to track customer orders. In the Cus- tomers table, each customer is identified by a field named CustomerID, which serves as that table's primary key. In the Orders table, which stores the details of each customer's orders, the CustomerID field is included as well. In this table, the CustomerID field is known as a foreign key . It relates each order in the Orders table to a customer in the Customers table. Here are the steps to follow to designate a primary key field in the Greetings table. Define a primary key 1. 2. In the Table Design window, click in the CampaignID field. On the Edit menu, click Primary Key. (You can also click the Primary Key button on the toolbar.)