| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (7 out of 17)

Defining an Inverse Relation

When defining a relation, you can also define an inverse relation, which is a relation between a relation target (the second class) and a relation source (the first class). You specify the name of the inverse in the Inverse-of-relation attribute.

The following figure shows a relation and an inverse relation between two objects, A and B. The relation X is the relation name, and the relation Y is the inverse relation. The arrow between the two objects represents the relation.


If you define a relation with an inverse, concluding an instance of that relation also concludes an instance of the inverse relation.

Concluding an inverse relation automatically concludes the relation. For example, if A is the First-class and B is the Second-class, you can conclude that A is related to B, or that B is related to A.

For example, the relation previous-linestation-for could specify an inverse relation named next-linestation-for, as this table shows.

For an inverse relation, when you conclude this relation... G2 also concludes this inverse relation...
grinding-station-1
is the-previous-linestation-for
rinsing-station-2

rinsing-station-2
is the-next-linestation-for
grinding-station-1


Note: If you have specified an inverse relation, you cannot also specify that the relation is symmetrical. The Relation-is-symmetric attribute must be no. A symmetrical relation creates its own inverse relation, which has the same name as the relation, as described in Defining a Symmetric Relation.

The inverse of a relation has the inverse cardinality of that relation, as this table shows.

If the relation's cardinality is... then its inverse relation is...
One-to-one
One-to-one
One-to-many
Many-to-one
Many-to-one
One-to-many
Many-to-many
Many-to-many

To create an inverse relation:

  1. Enter any allowable value in the Type-of-relation attribute.

  2. Use the default value of no for the Relation-is-symmetric attribute.

  3. Enter a name for the inverse relation in the Inverse-of-relation attribute.


Note: G2 prevents you from specifying a value for the Inverse-of-relation attribute when the Relation-is-symmetric attribute is yes.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (7 out of 17)

Copyright © 1997 Gensym Corporation, Inc.