Unit 3. Creating data tables (II)
We will fill in the grid defining each of the columns that compose the table: |
When we choose a type for the data, at the bottom of the window, the Field properties section is activated so as to be able to indicate more characteristics for the field, we will look at these characteristics in detail in the next unit. |
Press ENTER next to go to the third column of the grid. It is not necessary to use this column as it only serves to write comments; usually a description of the field for the person who will be introducing data so as to know what to write, this comment will appear on the status bar on the data page. Repeat the process until all the fields (columns) in the table have been defined. |
The primary key |
Before saving the table we need to assign a primary key. The primary key provides a unique value for each row in the table and serves to identify the records in such a way that with this key we can be sure of not mistaking the record being identified. In a table we can not define more than one primary key, but we can have a multiple-field primary key (one primary key defined on several fields. To assign a primary key to a field follow these instructions: Click on the name of the field that will be the primary key. Click on the Primary key button On the left of the field name will appear a key indicating to us that this field is the primary key of the table. If we want to define a multiple-field primary key (based on various fields), hold down the Ctrl key and click on all those fields, then click on the Important: Remember that a field or group of fields forming the primary key of a table cannot contain null values and neither have two rows in the table with the same value in the primary key fields. When we try to insert a new row with values that infringe on these two rules the system will not allow us to create the row and will return an error.
|
Saving a table. |
To save a table we need to:
As our table does still not have a name, the following dialogue box will appear: |
Write the name of the table. Click on the OK button.
|
Note: If we have not assigned a primary key before saving the table, a dialogue box will appear advising us of this, and asking whether we would like Access to create one like this: If we decide Yes, it will create a Autonumber field and will define it as the primary key. If we decide No, the table is saved without a primary key, a primary key is convenient but not obligatory.
|
Closing a table. |
To close a table, follow these steps:
|
To practise what you have learnt, you can perform the Step by step Exercise Tables Creation.