Defining a Primary Key


Every table in a relational database should have a primary key. Telling Access 2007 how to define the primary key is quite simple. Open the table in Design view and click the row selector to the left of the field you want to use as the primary key. 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.

For details about designing primary keys for your tables, see Article 1, “Designing Your Data-base Application,” on the companion CD.

After you select all the fields you want for the primary key, click the Primary Key button in the Tools group of the Design contextual tab on the Ribbon. Access 2007 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 “Adding Indexes” on page 888. 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 27–22.

image from book
Figure 27–22: You can easily define the primary key for the Companies table by selecting the field in Design view and clicking the Primary Key button on the Ribbon.

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




2007 Microsoft Office System Inside Out
2007 MicrosoftВ® Office System Inside Out (Bpg-Inside Out)
ISBN: 0735623244
EAN: 2147483647
Year: 2007
Pages: 299

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