Creating relation types

Last updated on
30 April 2025

Your site may have many different types of relations, containing different information and being used for different purposes. This is managed by having different relation types – similar to how your site may have different content types. (Technically, both content types and relation types are bundles of their respective entity types.)

Creating a relation type

To use the Relation module on your site, you need at least one relation type. At the administration toolbar > Structure > Relation types, you find a list of all available relation types along with a link to add new ones.

The relation creation screen provides the following options:

  • Label: This is the name of the relation. It is usually only displayed to administrators, but if using the natural language formatter for the Relation Dummy Field (see separate section), it will also be displayed to end users. If so, you should strive to have the label expressed as a predicate, such as "is sibling to" or "is creator of".
  • Machine name: A machine name is suggested based on the relation label, but can be edited manually too.
  • Directional: For directional relation types, Relation will treat the first referenced entity as the source and the other entities as targets. While this has some effects on how you set up your relation, and for example how it can be used with Views, it does not affect how the internal data of the relation. Your use case determines if your relation should be directional or not.
    • Reverse label: If you are setting up a directional relation, you will get a chance to set up a reverse label – used to indicate the reverse relation. For example, an "is creator of" relation could have the reverse label "was created by".
  • Available source bundles: This option specifies which types of entities can be included in the relation. All entity bundles available on your site are listed – such as specific content types and taxonomy terms divided by vocabularies. If you want to restrict on entity type only, and not by bundle, select "all [entity] bundles". You may select multiple entries, even from different entity types.
    • Available target bundles: If your relation is directional, the target bundles are set up separately from the source bundles.
  • Advanced options
    • Transitive: Relations that "pass on" its relatedness are called transitive relations. One example is "is sibling with", since if Alice is sibling with Bob and Bob is sibling with Eve, then the relation passes on the relatedness and Alice is sibling with Eve too. However, the Relation module does not provide nor use this extra relationship in any way – it is merely an information flag to be used by other modules.
    • Unique: If this option is checked, no relations with the same end points as an existing relation (of the same type) will be allowed.
    • Minimum arity: This defines the minimum number of end points for the relation. Currently it is only possible to select between 2/3/4/5/8 end points.
    • Maximum arity: This defines the maximum number of end points for the relation. Currently you have the same options as for minimum arity, plus infinite.

Adding fields and editing relation types

At the administration overview of relation types there are links for editing the properties for each relation type, as well as managing fields attached to each type (and how they are displayed). The edit screen for relation types is identical to the creation screen described above. Fields are managed in the same way as for other (fieldable) entities.

All relation entities have the endpoints field, provided by the (required) Relation Dummy Field module. The only available formatter for this field is the endpoints table, displaying a table of all the endpoints included in the viewed relation. There are no view modes defined for the Relation entity.

Help improve this page

Page status: Not set

You can: