1-866-245-5224 sales@keystonelearning.com

Access 2003: Setting Primary Keys

Access 2003: Setting Primary Keys

The primary and foreign keys determine how the tables in your database relate to each other. Further, a primary key is a field (or combination of fields) that contains a value that uniquely identifies a record.

Primary key fields:

     
  • Have values that are never blank
     
  •  
  • Include as few fields as necessary
     
  •  
  • Never allow duplicates
     
  •  
  • Can be any data type
     

Each table should always have a primary key. In fact, Access automatically creates an index for the primary key which helps speed up queries and other operations. Access also ensures that every record has a value in the primary key field, and that it is always unique.

When you create a new table in Datasheet view, Access automatically creates a primary key for you and assigns it a field name of “ID” and the AutoNumber data type.

Setting the Primary Key

     
  1. View your table in Design View
     
  2.  
  3. Select the field (or fields) that you want to use as the primary key
     
  4.  
  5. Choose the Primary Key command on the Standard toolbar
     

Removing the Primary Key

     
  1. View your table in Design View
     
  2.  
  3. Select the field (or fields) that contain the primary key you want to remove
     
  4.  
  5. Choose the Primary Key command on the Standard toolbar