To define a connection between two classes use the keyword relation. This relation can have 1:1, 1:n or n:m cardinality. A relation can have its own properties.
A special case is a “self-relation”, when the two related classes are identic.
Syntax |
// relation without properties // relation with properties //self-relation |
In order to facilitate the use of relations app.ducx implicitly defines the necessary attributes to have access from the relation instance to the class instances and from class instances to the relation instance. For the relation<ClassA, ClassB> Relation the implicitly defined attributes have the following names:
Name | Container | Type |
relation_classa | Relation | ClassA |
relation_classb | Relation | ClassB |
classa_relation | ClassA | Relation |
classb_relation | ClassB | Relation |
Table 9: Implicitly defined attributes for a relation
In case of the self-relation relation<Class> Relation:
Name | Container | Type |
relation_class1 | Relation | Class |
relation_class2 | Relation | Class |
class_relation | Class | Relation |
Table 10: Implicitly defined attributes for a self-relation
If ClassA is marked as multiple, then classb_relation is a list: instances of ClassB can have a set of Relation instances with different instances of ClassA.
Example |
objmodel APPDUCXSAMPLE@200.200 //1:n relation: //n:m relation: // self-relation |
For instance, assume at a company several employees can be hired. This can be modeled as a 1:n relation called Employee between the Company and Person class. In our case, the contractid and membersince properties could describe the Employee relation.