You are here: Commands > Relations > Command Mode Syntax

Command Mode Syntax

In command mode, use Define, Delete and Display commands to work with relations.

Defining Relations

Use the Define Relation command to create a relationship between a parent and a child table on a common key field, using a specified index for the child table.

DEFINE RELATION key-field-name WITH related-table-name INDEX index-name <AS relation-name>¿

key-field-name specifies the key field or expression of the parent table. You can select only one field for each relationship.
related-table-name specifies the related (child) table.
index-name specifies the index for the key field of the related table. In command mode, you must index the related table on the key field prior to relating the table. See Index.
relation-name specifies a unique name for the relation. By default, the Relations command uses the name of the related table as the relation name. When specifying additional relationships to the same table, specify a different, unique name.

For example, if the accounts receivable table is open, you can relate it to the Customer table using the parent customer number (No) as the key field as follows:

DEFINE RELATION No WITH Customer INDEX Customer_on_No

where Customer_on_No is the Customer table index on the No field. You must index the related table on the key field before relating the tables. See Index.

Deleting Relations

Use Delete Relation command to delete any relationship that has no dependent relations and no related fields referenced in either the current View or in an active computed field.

DELETE RELATION <relation-name>

relation-name specifies which relation to delete. If you do not add the qualifier, Analyzer deletes the last relationship defined. See Delete for details.

Viewing Relationship Details

Use the Display Relation command to View details of existing relationships for the current table. Analyzer lists the related-table-layout-name related on key-field-name using the index called index-name.

DISPLAY RELATION

Here is an example of possible output:

'Customer' related by 'No' using index 'Customer_index'