- Will the data in the field be unique for each record?
- Will the field always contain data?
- Will the data in the field remain the same over time?
- Last name: fails questions 1 and 3. Multiple people can have the same last name. Last names can change when people get married.
- Social security number: fails question 2. International students would not have a social security number.
- Student ID Number: passes all three questions.
Within Access, primary keys are designated by a key symbol when viewing a table in design view. The image belows shows the Pets table from the Menagerie Kennel database in design view. To the left of the Field Name ‘PetID’ is a small gold key. The key indicates that the field named PetID is the primary key for the Pets table. As the database developer you can set a primary key or Access will create one for you. If Access creates a primary key for you it will name the field ‘ID” and choose the data type of AutoNumber. The data in the field will automatically and sequentially count up from 1 each time a new record is entered into the table. No number will ever be repeated.
If you choose to set the primary key you then have control over the field name and the data type. There are different ways to set the primary key depending on how the table is set up in the database. Those will be explored in the next unit and demonstrated in video tutorials.