- Creating a Custom Database Template
- Planning Tables
- Creating Tables in a Database
- Creating a Table by Entering Data
- Creating a Table Using a Template
- Importing Data into Tables
- Linking to Data in Tables
- Working with Table Records
- Working with a Table in Design View
- Specifying a Primary Key in Design View
- Planning Table Relationships
- Defining Table Relationships
- Creating and Printing a Table Relationship Report
- Ensuring Referential Integrity
- Identifying Object Dependencies
- Modifying Object Dependencies
Specifying a Primary Key in Design View
A primary key is one or more fields in a table that provide a unique identifier for every row. You use the primary key in other tables to refer back to the table with the primary key. In Design view, you can use the Primary Key button to assign or remove the primary key designation for the selected field or fields. When you create a new table in Datasheet view, Access automatically creates a primary key and assigns it the field name “ID” and the data type AutoNumber. When you create a table in Design view, you can specify more than one field as a primary key, known as a composite key, so you are responsible for determining the data type of the primary key. Whatever data type you choose, values for the primary key must be unique for each table record.
Specify a Primary Key
In Design view, create a field that will be that table’s primary key, and then select an appropriate data type.
- If you choose the AutoNumber data type, Access assigns a value to the primary key for a new record that is one more than the primary key in the previous record.
- If you choose any other data type, such as Text, Number, or Date/Time, during data entry, you must enter a unique value in the appropriate format for the primary key of each new record.
Click the row selector of that field.
- To create more than one primary key, press and hold Ctrl, and then click the additional row selector for each field.
Click the Primary Key button.
To remove a primary key, delete any table relationships associated with the primary key, select the row selector for the Primary key, and then click the Primary Key button.