Creating Foreign Keys 

Procedure

  1. In the field maintenance screen of the table, select the check field and choose Goto ® Foreign key.
  2. If the domain of the check field has a value table (* entry in the Chk.table column), you can let the system make a proposal with the value table as check table.

    If the domain does not have a value table or if you reject the proposal, the screen for foreign key maintenance appears without proposals. In this case, enter the check table and choose Save. The check table must have a key field to which the domain of the check field is assigned.

    You can then let the system make a proposal for assigning the foreign key fields to the key fields of the check fields. The system attempts to assign the key fields of the check table to fields of the table with the same domain. If you do not want a proposal, the key fields of the check table are listed and you must assign them to suitable fields of the foreign key table.

  3. Enter an explanatory short text in the field Short description and save the foreign key.

Other Options

Removing Fields from the Assignment

You can remove foreign key fields (with the exception of the check field) from the assignment to the key fields of the check table (see Generic and Constant Foreign Keys).

Select Generic to remove a field from the check against the key fields of the check table. If you want to assign a constant to a foreign key field, you must enter it in the Constant field enclosed in apostrophes (for example: ‘Constant’).

If you select the Generic flag for a field, or enter a constant, you must remove the entries for the table name and field name in the Foreign key field column.

Switching off the Value Check

If the foreign key should not be used for a value check in screen fields, you must remove the selection in the Screen check wanted field.

This definition is valid for all screens in which the field appears. For example, it could make sense to switch off the check if the foreign key is only used to define aggregated objects.

Assigning Messages

A standard message is output if the value check by the foreign key on the screen field results in an invalid input.

You can replace this standard message with any message in table T100. To do this, you must enter the message class of the message in the field AArea and the message number in the field MsgNo.

Defining the Cardinality and Type of the Foreign Key Fields

You can define the relationship defined by the foreign key between the foreign key table and check table in greater detail by specifying the cardinality and type of the foreign key fields (see Semantic Attributes of Foreign Keys).

If the foreign key is derived from a field of an included table or structure (see Substructures), the Inherited from the included substructure flag is also displayed. Foreign key definitions are usually inherited from the included table to the including table, so that the foreign key depends on the definition in the included table.

The flag is normally set. If you cancel the selection, the link between the foreign key and the included table is canceled. The foreign key no longer adjusts itself when its definition in the included table changes.

See also:

Foreign Keys