Contents Index Lesson 3: Design and create a table Lesson 5: Design column properties

ASA Getting Started
  Designing and Building Your Database
    Tutorial: Design and build a simple database

Lesson 4: Identify and create primary keys


In this lesson, you learn more about defining primary keys for your tables. There is no exercise associated with this lesson.

For more information, see Tables have a primary key.

Concepts 

The primary key is a special column or columns used to uniquely identify a row in a table. In the product table, the id column uniquely identifies each product.

The Product table.

Each row has a unique value for the id column, and the values in each row pertain only to a single product identifier by its id value. Two products might have the same name or the same size, but not the same id number. In the diagram, the id column is underlined to show that it is a primary key.

Creating a column specifically to hold an identifier which has no other meaning is common practice in database design. You will know from your bank, utility, or credit card statements that each account has a unique identifier.

Using an AUTOINCREMENT primary key 

You can make entering primary keys simple by assigning a primary key column a default value of AUTOINCREMENT. The value for this column is entered automatically each time a new row is added, and its value is one more than the field's value for the last row added.

To create an AUTOINCREMENT primary key

  1. Select the product table in the left pane and then click the Columns tab in the right pane.

  2. Select the primary key column. From the File menu, choose Properties button to open the property sheet for the column.

  3. Click the Value tab.

  4. Select the Default Value option.

  5. Click System-defined, and choose Autoincrement from the dropdown list.

  6. Click OK to close the column property sheet.

  7. To finish, choose File > Save Table.


Contents Index Lesson 3: Design and create a table Lesson 5: Design column properties