Last updated August 17, 2015. Created on September 10, 2011.
Edited by mikran, diqidoq, femaltol, wayaslij. Log in to edit this page.

Conceptual image of relations

The Relation module provides an API and basic user interface for creating and managing relations between entities on your Drupal site.

The Relation module is similar to modules like Entity Reference and References (node reference and user reference), but has some important differences:

  • Relations are their own entities, existing strictly outside both entities they relate to (where references are attached to the source entity).
  • Being separate entities, relations are also fieldable (where references are not).
  • Relations can include multiple endpoints (where references only have two).
  • Relations can be directional or symmetrical (where references always have an explicit starting point – thereby being directional).

These properties allow more complex information structure on your site, but also make relations more complex to set up compared to references. It should be noted that while the Relation module has a UI for managing relations, it is to a large extent an API module for other modules to implement.

Relation has good integration with the Feeds, Migrate, Views and Rules modules – see separate sections for details on how to utilize this.

Some use cases

  • Relations can relate more than two entities:
    areSiblings -> (john, jen, jack, jess)
  • Relations with two endpoints, 2-ary or binary relations, can be directional:
    bruno -> isChildOf -> boglarka
  • Directional relations automatically provides a reverse relation:
    boglarka -> isParentOf -> bruno
  • 1:n directional relations are also possible:
    john -> playlist -> (Song A, Song B, Song C)
  • Relations are fieldable: on the relation
    CompanyA -> donation[123] -> PartyB,
    donation[123] may have fields for amount, date, message, etc.
  • Being entities, relations can relate to other relations:
    CompanyA -> donation[123] -> PartyB and
    donations[123] -> transaction[456] -> BankC
    (that is, "Company A made a donation to Political Party B, via Bank C"). See the RDF spec for n-ary relations for more information about relation descriptions. [Note: this isn't a standard, and may never be]).

View a screencast introducing the Relation module

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

johnhorning’s picture

The screencast link doesn't seem to be working.
John

cbd11’s picture

You have to click the vimeo link presented over the video, or directly go to : http://vimeo.com/28178686

diqidoq’s picture

so why don't you edit the page and put the new link in ? I'll do it for you.