Type Hierarchy: Inheritance, Containment & Aggregation

Intermediate

How to use the Type Hierarchy flags on a relationship type — inheritance (inherit properties, allowed connections, views), containment (nesting on the canvas and in the tree), and aggregation.

Every Relationship Type can carry semantic flags that change how its connections behave — beyond just drawing a line. Select a Relationship Type in the Model Navigator, open the Properties panel, and find the Type Hierarchy section. The flags are independent — turn on only the ones you need.

Inheritance flags

Use these when a relationship means "is a kind of" (e.g. an is_a link from Electric Car to Car). The child type then picks up things from its parent:

  • Inherit properties — the child gains the parent's properties. They show on the child (greyed/italic) and on every instance of it; edit them on the parent.
  • Inherit allowed connections — the child can connect anywhere the parent can.
  • Inherit views — the child uses the parent's visual style unless overridden.
  • Share auto ID sequence — the child numbers from the parent's auto ID sequence instead of its own, so a parent and all its subtypes run one series (REQ-1, REQ-2, REQ-3…). See Automatic IDs (Auto ID).

As you model (in the app and via the API), a type may have one parent, and cycles are rejected.

Changing a type's supertype

To move a type to a different parent, or to make it a root type, select the node type and find Supertype in its Properties panel:

  1. Click Change supertype….

  2. Pick the new parent, or (none – make it a root type). If the model has more than one inheritance relationship type, choose the Inheritance relationship as well.

  3. Metapad lists what will change before anything happens:

    • relationships the new hierarchy no longer allows, which will be deleted;
    • property values on properties that are no longer inherited, which are hidden but stay in the data;
    • auto-IDs that are already taken in the new sequence, which will be renumbered.

    If nothing changes, it says so.

  4. Click Change supertype.

The move is a single step, so one Undo puts the type back under its old parent. It is refused if the type has a property with the same name as one it would inherit from the new parent: rename one of the two first.

Containment (nesting)

Turn on Containment (nesting) when a relationship means "is part of / is inside" (e.g. an Engine inside a Car). Connections of that type render as nesting instead of a line:

  • On the canvas, the contained element sits inside its container as a box-in-box. The container grows to fit its contents, and dragging the container moves everything inside it. The connecting line is hidden — the nesting is the relationship.
  • Look inside a container: double-click it and its contents fill the view. Double-click a container inside it to go deeper. A breadcrumb in the top-left shows where you are. Click Back, press Esc or click a breadcrumb entry to go back out. This only changes your own view: the diagram itself and your collaborators are not affected. To rename a container, select it and press F2.
  • In the Model Navigator tree, the contained element appears beneath its container.

Drill-down into the App Server on the C4 zoom diagram

Two levels deep in the C4 template: the breadcrumb reads Zoom › Metapad › App Server, and the App Server's components fill the view.

Direction matters: draw the connection from the contained element to its container (source = the part, target = the whole).

Only want to draw one element inside another, without it belonging to the container in the tree? See Show a relationship by nesting.

Aggregation

Aggregation marks a weaker "part of" relationship (shared parts, independent lifecycle) for documentation. It has no visual effect on its own — the connection stays an ordinary line. For a UML-style hollow diamond, set a Diamond arrow end in the relationship type's styling (see Styling Relationship Types).

Abstract types

Some types exist only to share rules with their subtypes. An Element type might, for example, carry properties and allowed connections that every concrete element type inherits. Mark such a type as abstract:

  1. Select the Node Type in the Model Navigator.
  2. In the Properties panel, tick Abstract.

An abstract type has no nodes of its own. It is not offered in the Toolbox or in the menus for creating nodes, and you can't change an existing node to it. Its name is shown in italics on the metamodel diagram and in the Model Navigator.

It still works as a search target: searching, filtering or building a grid view by an abstract type finds the nodes of all its subtypes. For example, "all Behavior elements" finds every node of every Behavior subtype. A type that is not abstract only ever matches its own nodes.

You can't mark a type abstract while it still has nodes. The checkbox is disabled and tells you how many there are. Change or delete those nodes first.

Locked types

Lock a type when other models, templates or imports depend on it staying as it is. You can still extend a locked type, but you can't break it.

  • Lock or unlock one type: select it and click Lock type or Unlock type in the Properties panel.
  • Lock or unlock the whole metamodel: right-click the Node Types or Relationship Types section in the Model Navigator and choose Lock whole metamodel or Unlock whole metamodel.

A padlock marks a locked type on the metamodel diagram and in the Model Navigator.

Not possible on a locked typeStill possible
Delete itAdd subtypes, properties and allowed connections
Rename itTranslate its name and property names
Remove, rename or change the data type of a propertyChange its description, color, shape, icon and default size
Change its supertypeChange line and arrow styles
Remove an allowed connection between locked types

When something is refused, the message names the lock and tells you how to unlock. Any editor can unlock a type. Unlocking is a step of its own, and Undo locks the type again.

Tip: when you build a metamodel to lock, set up the supertypes first, then lock.

Good to know

  • All flags default off, so existing models are unchanged.
  • The flags are independent: a relationship can nest without inheriting, or inherit without nesting.

This content was written collaboratively with AI.