Up Previous Next Title Page Contents

3.4 Creating relationships

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-10 and metamodel in Figure 1-3, we now have to define Family, a relationship between Parents and Children.

Figure 3-10. 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 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.

To handle these kinds of issues, we need a new metamodeling structure known as a binding. A binding contains the information on which objects can take part in a relationship in which roles, and how many times each role may occur. Each binding consists of one relationship, two or more roles, and for each role, one or more objects.

First though we need to define the relationship and roles. Start the Relationship Tool by pressing Relationship Tool toolbar button or selecting Metamodel | Relationship Tool in the MetaEdit+ launcher. The Relationship Tool looks and works just like the Object Tool. To create a new Family relationship type, enter ‘Family’ in the top-most text field (as in Figure 3-11).

Figure 3-11. Relationship Tool

As we do not want to include any properties in our Family relationship at this time, you can complete the generation of the new relationship type by pressing Save and Close button in toolbar (as the default symbol provided by MetaEdit+ for this new type is sufficient for our purposes, we do not need to worry about the symbol here).

Up Previous Next Title Page Contents