Create Relations

You can use a relation notation as convenient shorthand to represent multiple contexts.

A relation is a vertical list of similar contexts arranged horizontally. In other words, each row of a relation table is a context and each column consists of context entries, where the column name is the common key attribute for all cell entries under it that act as value attributes of respective contexts (rows). For details about contexts and key-value pairs, see Create Contexts. In a relation, each cell entry is an independent logical notation.

In the output of a relation notation, outputs of all contexts within it are clearly distinguished. You can also invoke the output of a particular context or context entry from another decision.

To create a decision with the Relation notation:
  1. Add a new decision element to the model.
    1. On the Diagram palette, under Decisions select Relation, and drag it onto the canvas.
    2. Double-click the element to edit its logic. You can also edit the element's logic from the Decision Properties pane; click the three dots on the element, then select Edit to open the Decision Properties pane. In the Decision Properties pane, click Edit Edit icon next to the Name field.
    An empty Relation table is created.
  2. Use add row/column buttons above the table to add additional rows or columns. All cells have expression notation selected by default.
  3. Enter a name for each column.
  4. Select a cell and click Change Value Change Value icon to change the logical notation for the cell. Select a different notation from the available options. Note that you cannot insert a decision table within a relation.
  5. Within cells, configure the logic. You can use input variables or built-in functions to define the logic.
  6. Changes you make within the decision model are automatically saved and validated from time to time. Errors and warnings, if any, are displayed within the decision panel.

Note:

If you add a function as one of the cell entries, then the relation as a whole doesn’t return a result. However, you will still be able to invoke results of other cell entries or contexts throughout the decision model.

The following relation contains the stock information for a particular brand of phone in the form of multiple contexts:



Similar to list notations, use either Phone[1] or Phone[-3] to access the entire context related to black-colored phones. To access all cell entries of a particular column, use the relation name in combination with the column name, for example, Phone.Price returns all entries of the Price column in a list. To access a particular context entry (for example, “Rose Gold”), use Phone.Color[3] or Phone.Color[-1].

The following image is the result of the entire relation, which has results of each context listed separately: