Datasheet

Default Value
An important database concept, Default Value can help save time in the data
entry process. The default value is automatically placed in a column every
time a new record is added. Defaults can be overridden, so your column is not
forced to have only that particular value.
Required
Another important property, Required simply forces a user to enter some
value, using the proper data type, in the designated field. A new record will
not be added if the Required field is not properly filled. As with Input Mask,
this property is an excellent mechanism for asserting more control over the
data entry process.
Primary key
You will recall that earlier in the chapter, you needed to ask yourself three
questions to determine just how a new table was to be created. The third ques-
tion specified that you need a way to identify or reference every record. In
other words, there needs to be some unique text or number column that will
have no duplicate values, in much the same way that Social Security numbers
uniquely identify individuals. Each person has one and only one Social Secu-
rity number. By definition, you cannot have a Social Security number that rep-
resents two people. This unique column is known as a primary key and it is the
mechanism by which you relate different tables to each other.
To set the primary key, right-click the field that could be a primary key can-
didate and select Primary Key.
At this point, Access will automatically determine if that particular field
contains duplicate data—that is, data items that exist in more than one row.
If there are duplicates, Access informs you with an error message. You must
remove any duplicates if that column is indeed to become the primary key for
the table.
TIP Access provides its own automatic primary key with the AutoNumber data
type. The AutoNumber simply increments one for each record added, so there
will be no duplicates. However, it is preferable to use actual data for a primary
key and not just some number that indicates the record’s position in a table.
If every employee has a unique employee number, that field would be an ideal
primary key. If you have a situation where there is no unique single column,
consider using a combination of columns that together make up a unique
record. You can set multiple columns to be the primary key; this is called a
Compound Key. It has the effect of combining separate columns to represent a
single, unique value.
14 Chapter 1
05_59978X ch01.qxp 12/1/05 7:46 PM Page 14