« Back

Definition of relation classes

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Definition of relation classes
community relation documentation
Answer
3/27/14 11:04 AM
How to define and restrict relation classes has been discussed. On one hand through the definition of an appropriate class hierarchy, included abstract classes where needed to setup the rules implicitly, but also using cardinalities for modeling classes?

RE: Definition of relation classes
Answer
1/20/14 11:49 AM as a reply to Fadi.
On one hand through the definition of relation classes is restricted by setting up an appropriate class hierarchy, including abstract classes where needed to define the rules implicitly, but also using cardinalities for modeling classes.

a) Class Hierarchy:
The class hierarchy should be defined in a way that relation classes and the respective rules are implictly derived through inheritance of endpoint definition. For each relation class the corresponding start and endpoint can be defined also using abstract classes. Therefore a review of the class hierarchy in corrspondence with the relation class rules is proposed.

b) Class caradinalities
For each modelling class, class cardinalty rules can be defined. These rules are evaluated triggered by user interaction (the user clicks in "Model" -> "Check cardinalities" and ADOxx will validate the model against the cardinalities defined. The language to define cardinalities is defined as follows and has to specified in the class attribute "Class cardinality" available by default for each modelling class:

1CARDINALITIES
2              [ max-objects:NumValue ]
3              [ max-relations:NumValue ]
4              [ max-outgoing:NumValue ]
5              [ max-incoming:NumValue ]
6              { RelationCardinalities }
RelationCardinalities :  
1RELATION "RelationName"
2         [ max-outgoing:NumValue ]
3         [ max-incoming:NumValue ]
4         [ default-max-outgoing:NumValue ]
5         [ default-max-incoming:NumValue ]
6         { ToClassCardinality | FromClassCardinality }

ToClassCardinality :  
1TO_CLASS "ClassName"
2         [ max-outgoing:NumValue ]

FromClassCardinality :  
1FROM_CLASS "ClassName"
2           [ max-incoming:NumValue ]
where

NumValue: A number between 0 and 65535.
RelationName: Expression for a Relation.
ClassName: Expression for a Class.
  • The expression max-objects specifies the maximum number of objects of this class which may exist in a model.
  • The expression max-relations specifies the maximum number of relations which may be connected to an object of this class.
  • The expression max-outgoing specifies the maximum number of outgoing relations from an object of this class.
  • The expression max-incoming indicates the maximum number of incoming relations to an object of this class.
  • The expression max-outgoing within CARDINALITIES specifies the maximum number of relations which may start at an object of this class.
  • The expression max-incoming within CARDINALITIES specifies the maximum number of relations which may end at an object of this class.
  • These restrictions may be further restricted by the expression RELATION for as many relation classes as desired.
  • The expression max-outgoing within RELATION specifies the maximum number of relations which may start at an object of this class.
  • The expression max-incoming within RELATION specifies the maximum number of relations which may end at an object of this class.
  • The expression default-max-outgoing specifies the maximum number of objects (of the same class) from which originating relations of the respective relation type may exist. A default value is specified which applies to all target classes which are not explicitly named by the expression TO_CLASS.
  • The expression default-max-incoming specifies the maximum number of objects (of the same class)  from which relations of the respective relation type may lead to an object of the current class. A default value is specified which applies to all classes which are not explicitly named by the expression FROM_CLASS.
  • The expression TO_CLASS defines the maximum number of relations of the particular relation type which may lead from an object of the current class to objects of the same class. For the class specified the default value defined by default-max-outgoing will be overwritten.
  • The expression FROM_CLASS defines the maximum number of relations of the particular relation type which may lead from objects of this class to an object of the current class. For the class specified the default value defined by default-max-incoming will be overwritten.
The modelling toolkit does not evaluate class cardinalities during the design task by default but only through user interaction. This can be changed in the library attribute "Default settings" by adding the following statement

1CHECK_CARDINALITIES before-save:boolVal after-modeling-action:boolVal

and setting the boolVals accordingly.