Creating Foreign Keys

Proceed as follows in the field maintenance screen of the table to maintain foreign keys:

  1. 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 for the foreign key. The value table is entered as check table and fields of the foreign key table are assigned to the key fields of the check table with the same domain (if possible). You can then continue processing the proposal.

    If the domain does not have a value table or if a proposal was not made, the screen for foreign key maintenance appears without proposals. 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 of 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 text.
  4. 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).
  5. Select generic to remove the 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 a field as generic or enter a constant, you must remove the entries for the table name and field name in the Foreign key field column.

  6. 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. Deactivating the screen check could make sense for example for testing purposes. It could also makes sense to deactivate the flag if a foreign key is only used to define aggregated objects.
  7. A standard message is output if the value check by the foreign key on the screen field results in an invalid input.
  8. This message can be replaced by any message in table T100. In this case you must enter the application area (AppAr) or message number (MsgNo).

  9. Describe the relationship between the foreign key table and the check table defined by the foreign key by specifying the cardinality and type of the foreign key fields (see Semantic Attributes of a Foreign Key). This information is optional.

If the foreign key is derived from a field of an included table or structure, 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 will be canceled. The foreign key no longer adjusts itself when its definition in the included table changes.

See also:

Foreign Keys