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

Replacing a Relation

In general, when concluding a relation, G2 signals an error if you attempt to conclude a relation that violates the relations's cardinality. You can use an alternative form of the conclude action to break existing relations before concluding a new relation.

To replace a relation between items or classes:

Using the Now Syntax

When you use the now syntax, G2 determines whether adding the instance of the relation violates the cardinality of a relation. If it does, G2 deletes the conflicting relation when it establishes the new one.

For example, suppose not-responding-on is a one-to-one relation between a node and a network and you conclude the following relation:

Then, suppose you conclude the following:

This causes G2 first to delete the not-responding-on relation instance between node-1 and network-1 and then to establish a new not-responding-on relation between node-1 and network-2.

When replacing a one-to-one relation, G2 deletes existing relations in which the relation source or the relation target participate before creating a new relation. When replacing a one-to-many relation, however, G2 only breaks the existing relation between the relation target and another item; it leaves intact any existing relations between the relation source and another item. G2 does not break any existing relations when replacing a many-to-many relation.

The following table shows how relations are deleted, if necessary, according to the type of relation:

For this type of relation... G2 deletes the existing relation instance with items of...
one-to-many
the second class
many-to-one
the first class
one-to-one
the first and/or the second class

Example of Replacing a One-to-one Relation

For example, assume computer-1 is related to computer-2 by an in-communication-with relation. The following action button breaks the relation between computer-1 and computer-2, and creates a new in-communication-with relation between computer-1 and computer-3. The cardinality of the relation is one-to-one.


Example of Replacing Multiple One-to-one Relations

Suppose computer-1 is related to computer-2, and computer-3 is related to computer-4, both via an in-communication-with relation. The action button in this figure breaks both existing relations, and creates a new in-communication-with relation between computer-1 and computer-4.


Example of Replacing a Many-to-one Relation

Suppose computer-1 is related to computer-2, and computer-3 is related to computer-4 via a many-to-one relation. The action button in this figure breaks the existing relation between computer-1 and computer-2, and creates a new in-communication-with relation between computer-1 and computer-4. Notice that computer-3 is still related to computer-4 because the relation allows more than one relation source to be related to the same relation target.


Example of Replacing a One-to-many Relation

Suppose computer-1 is related to computer-2, and computer-3 is related to computer-4 via a one-to-many relation. The action button in this figure breaks the existing relation between computer-3 and computer-4, and creates a new in-communication-with relation between computer-1 and computer-4. That computer-1 is still related to computer-2 because the relation allows for one relation source to be related to more than one relation target.



Note: If the computers were related via a many-to-many relation, G2 would not break any existing relations.

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

Copyright © 1997 Gensym Corporation, Inc.