Microsoft Office Tutorials and References
In Depth Information
Specifying the Primary Key
The fi fth, and fi nal, fi eld to be defi ned in the Invoice table is InvoicePaid. This fi eld
will be a Yes/No fi eld to indicate the payment status of each invoice record stored in the
Invoice table. Recall that the Yes/No data type is used to defi ne fi elds that store true/false,
yes/no, and on/off fi eld values. When you create a Yes/No fi eld in a table, the default
Format property is set to True/False. After setting the data type, you’ll set the Format
property for the InvoicePaid fi eld to Yes/No.
To define the InvoicePaid field:
1. Click the fifth row’s Field Name box, type InvoicePaid , and then press the Tab
key to advance to the Data Type box.
2. Type y. Access completes the data type as “yes/No.”
3. Press the Tab key to select the Yes/No data type and move to the Description box.
4. Click the Format box, click the arrow on its right side, and then click Yes/No to
set the Format property.
5. Press the Tab key to move to the Caption box, and then type Invoice Paid .
You’ve fi nished defi ning the fi elds for the Invoice table. Next, you need to specify the
primary key for the table.
Specifying the Primary Key
As you learned in Tutorial 1, the primary key for a table uniquely identifi es each record
in a table.
Understanding the Importance of the Primary Key
Although Access does not require a table to have a primary key, including a primary key
offers several advantages:
• A primary key uniquely identifies each record in a table.
• Access does not allow duplicate values in the primary key field. For example, if a
record already exists in the Contract table with a ContractNum value of 3020, Access
prevents you from adding another record with this same value in the ContractNum
field. Preventing duplicate values ensures the uniqueness of the primary key field.
• When a primary key has been specified, Access forces you to enter a value for the
primary key field in every record in the table. This is known as entity integrity . If you do
not enter a value for a field, you have actually given the field a null value . You cannot
give a null value to the primary key field because entity integrity prevents Access from
accepting and processing that record.
• Access stores records on disk as you enter them. You can enter records in any order,
but Access displays them by default in order by the field values of the primary key. If
you enter records in no specific order, you are ensured that you will later be able to
work with them in a more meaningful, primary key sequence.
• Access responds faster to your requests for specific records based on the primary key.
Search JabSto ::




Custom Search