• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Defining a Primary Key

Every table in a relational database should have a primary key. If you use the procedure outlined in Chapter 3, “Designing Your Database Application,” you should know what fields must make up the primary key for each of your tables.

Telling Microsoft Access how to define the primary key is quite simple. Open the table in Design view, and then select the first field for the primary key by clicking the row selector to the left of that field’s name. If you need to select multiple fields for your primary key, hold down the Ctrl key and click the row selector of each additional field you need.

After you select all the fields you want for the primary key, click the Primary Key button on the toolbar or choose the Primary Key command from the Edit menu. Access displays a key symbol to the left of the selected field(s) to acknowledge your definition of the primary key. To eliminate all primary key designations, see the section titled “Adding Indexes,” page 130. When you’ve finished creating the Companies table for the Contact Tracking database, the primary key should be the CompanyID field, as shown in Figure 4-26.

Figure 4-26. The Companies table with a primary key defined.


Be sure to click the Save button on the toolbar to save this latest change to your table definition.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint