How to Create a Key

Top  Previous  Next

Add and edit keys and indexes using the Keys pad found in the Quick View panel.

Keys are automatically updated whenever records are added, changed, or deleted. Index files do not update automatically. A BUILD statement is required to update an index.


Select a table from the DCT Explorer list on the Tables side of the Dictionary dialog and press the Add button found on the Keys pad.

The Key Properties dialog appears.


Type a valid Clarion label in the Label field.


Optionally type a Description. This displays in various dialog boxes, including the File Definition dialog.


In the Attributes and Type group boxes select a key type and check all boxes that are appropriate for the key.

A runtime index allows you to declare an index without specifying the key component fields in the Data Dictionary. The application must define the key component fields at runtime, as the second parameter of the BUILD statement. The application may rebuild the same index file at a later time, specifying different key component columns for the index.


Optionally type a valid DOS file name in the External Name field, if the file system needs one.

Clarion automatically adds the proper file extension.


Select the Columns tab, then press the Add button.

The Select a Field list appears.


DOUBLE-CLICK a field in the list;

This transfers its name to the Columns tab, which indicates the field will be part of the new key. Repeat steps 8 and 9 to add more fields to the key.


Press OK to close the Key Properties dialog.

The Key Properties dialog appears again, ready to accept additional keys.


Repeat steps 4 through 10 to create additional keys for this file.


When you are finished adding keys, press Cancel to close the Key Properties dialog and return to the Quick View panel.

At the end of the process, your keys appear in the Keys pad, with their field components arranged in order, one above the other in a tree diagram.

To modify a key, select the key and press the Change button in the Keys pad. The Entity Browser for that key’s table appears, and the Key Properties dialog appears just to the right of the Entity Browser. If you selected a key component, the Columns tab is on top. If you selected the key, the General tab is on top.


Next: How to Define Table Relationships and Referential Integrity