Understanding unique values
Without the ContactID field, you’d have to rely on another field or combination of fields for uniqueness. You couldn’t use the LastName field because two customers could easily have the same last name. In fact, you couldn’t even use the FirstName and LastName fields together (multi-field key), for the same reason— two people could be named James Smith. You need to come up with a field that makes every record unique.
Looking at the table, you may think that you could use a combination of the LastName, FirstName, and Company fields, but theoretically, it’s possible that two people working at the same company have the same name.
The easiest way to solve this problem is to add an AutoNumber field for the express purpose of using it as the table’s primary key. This is exactly the situation with the Contacts table. The primary key of this table is ContactID, an AutoNumber field.
If you don’t designate a field as a primary key, Access can add an AutoNumber field and designate it as the table’s primary key. This field contains a unique number for each record in the table, and Access maintains
it automatically.
Generally speaking, you may want to create and maintain your own primary key, even if you always use AutoNumber fields as primary keys:
- A primary key is always an index.
- An index maintains a presorted order of one or more fields that greatly speeds up queries, searches, and sort requests.
- When you add new records to your table, Access checks for duplicate data and doesn’t allow any duplicates for the primary key field.
- By default, Access displays a table’s data in the order of its primary key.
By designating a field such as ContactID as the unique primary key, you can see your data in a meaningful order. In our example, because the ContactID field is an AutoNumber, its value is assigned automatically by Access in the order that a record is put into the system.
// Related Posted - GOOGLE!
Related Websites
- Binoculars That Go the Distance You've got the perfect fishing trip planned, and your gear is set for an early start. Or is it? While...
- PokerStars Grand Lisboa Breaks Macau Player Field Record PokerStars Macau at Casino Grand Lisboa made history last weekend as the “Macau Millions” smashed the all-time record for player...
- Is Carlos Gonzalez A Product Of Coors Field? When Matt Holliday was traded away from the Rockies, I thought that perhaps the "product of Coors Field" factor was...
- Macau News October 2007 APEC says wait Macau will remain in the long queue of candidates seeking to join the Asia Pacific Economic Cooperation...
- Which Woodworking Power Tools you Need It can become extremely easy for someone like you to get confused by the incredible number of different tools that...
