Show in Frame No Frame
Up Previous Next Title Page Contents Search

3.5 Creating Relationship types

What do we need to do next? Let’s take a look at our problem domain specifications again. We have now created the concept of Person. According to our sketch in Figure 3-15 and metamodel in Figure 1-3, we now have to define Family, a relationship between Parents and Children.

Family Tree notation

Figure 3-15. Sketch of a graphical notation for the Family Tree

In addition to the Family relationship, we need concepts to represent the roles a Person can play in that relationship. Simply, a Person can be in either a Parent role or a Child role in a given Family. Visually, each of the lines going towards a Person is a role, and the central meeting point of the lines between the parents is the relationship.

Looking at things a little more carefully, we can see there are certain rules on how we are allowed to bind together Persons in a Family. For instance, in any given Family relationship there must always be exactly two objects in Parent roles, but there may be any number of objects in Child roles. We will specify those rules later with bindings. Having the rules separate, rather than a fixed part of the Object or Relationship type, keeps things more flexible and lets us reuse the types elsewhere, where the rules may be different.

First though we need to define the Relationship and Role types. Like the creation of the Object types, this can be done from the Graph Tool’s Types page. Start creating a new Relationship type: move the mouse cursor into the Relationships list on the Types page, click the right mouse button and select Add New... from the popup menu. This opens a new Relationship Tool, which looks and works just like the Object Tool. For our new Family relationship type, enter ‘Family’ in the Name field (as in Figure 3-16).

Relationship Tool

Figure 3-16. Relationship Tool

As we do not want to include any properties in our Family relationship at this time, and we don’t want a special symbol for it, you can complete the generation of the new relationship type by pressing the Save and Close button on the toolbar. The new Family relationship type is added to the Relationships list in the Graph Tool.

Show in Frame No Frame
Up Previous Next Title Page Contents Search