Adding a Relationship
Adding a relationship to a diagram can also be accomplished in one of two ways.
To use the Relationship tool in the toolbox, you must have two concepts already in the diagram. Once you’ve added another concept, click on the Relationship tool:
Then mouse over to the canvas (no need to drag the relationship), and click on the first concept of the relationship (the ‘from’ concept). When you now mouse away, you will see that the relationship has been anchored to the first concept:
Now click on the second concept, and the relationship between the two will be added:
Second Method for Adding a Relationship
The other method uses the context menu of an existing concept. This method will add the relationship as well as the concept that it is connecting to. If you start with an existing concept and select ‘Add To New Concept’ from its context menu:
The relationship is added with the arrow pointing from the original concept to the new concept:
If you select ‘Add From New Concept’:
The relationship is added with the arrow pointing in the opposite direction: from the new concept to the original concept:
Both context menu methods create a relationship and a concept– the only difference is the direction of the arrow.
Relationship Element
Let’s take a closer look at the Relationship element:
The default label for a relationship is ‘label’. It can be renamed in the same way as a concept– simply double click on the label and rename.
The lower section of the relationship shows the number of attributes attached to this relationship– currently 0. Relationship attributes are used when modeling Property Graph schemas– click here for information on adding relationship attributes.
Detailed Relationship Information
When a relationship is added or selected in the diagram, the detailed information for that relationship pops up in the left panel:
The detailed information panel for relationships contains all of the fields as for a concept, with the addition of one: Cardinality, explained below. These fields behave exactly the same as for a concept, except one: the IRI. If a new relationship is given the same label as an existing relationship, the IRI is re-used.
Also note: the number after the type of element, i.e., > CONCEPTS (2), or > RELATIONSHIPS (1) gives the number of elements that this element is attached to. Thus, for this example, we have a single relationship attached to two concepts.
Cardinality
Like attributes, relationships can also have cardinality. Suppose you had a Business concept connected to an Address concept through two relationships: ‘has address’ and ‘has shipping address’:
Suppose also that a Business can have multiple addresses for multiple locations (and has at least one location address)– but it can only have one shipping address for all shipments.
Cardinality for ‘has address’ would be ‘min 1’:
And for ‘has shipping address’ it would be ‘exact 1’:
Relationship Cardinality Export
Relationship Cardinality is exported as an owl:Restriction
on the appropriate Class:
Self-Referencing Relationships
A concept can have a relationship with itself. To add a self-referencing relationship, use the Relationship tool from the toolbox. Click on the concept you wish to add the relationship to, which will set it as the source. Click again on the same concept to set it as the destination: