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

Defining a Primary Key

As you learned in Chapter 3, it is important to define a primary key to uniquely identify each row in a table. Doing so allows you to define relationships with other tables and reduces redundant data. Also, you cannot update a table that does not have a primary key. Defining a primary key for a table in an Access project is very similar to defining a primary key in an Access desktop database (.mdb).

Remember, you didn’t define a primary key for the Companies table. Open that table again in Design view. To define a primary key, select the column that you want to make into a primary key—in this case, the CompanyID column. Then click the Primary Key button on the Table Design toolbar or choose the Primary Key command from the Edit menu. Access automatically creates a UNIQUE index on the selected column and creates a primary key named PK_Companies. Access displays a key symbol to the left of the selected column to acknowledge your definition of the primary key, as shown in Figure 17-15. Be sure to save your changes. Note that when you need to define multiple columns as the primary key, you can select a group of columns by holding down Ctrl and clicking on each one.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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