Relation is an API module and storage model for both simple and the most complex relations between entities. The module can handle both directional and symmetrical relations very well.

Relations are entities and can therefore have fields. This makes Relation the most flexible and powerful relation model out there.

Examples

John, Jen and Jack are siblings. This relation are symmetrical and points in all directions.

               |-- John
               |
Are siblings --|-- Jen
(relation)    |
               |-- Jack

CompanyA a made a donation to PartyB, with a transaction via BankC. Both relations (donation and transaction) are directional.

CompanyA   -->  DonationX   --> PartyB
(node)         (relation)      (node)

DonationX  --> TransactionY --> BankC
(relation)      (relation)      (node)

In the example above DonationX can have an integer field for the donation amount. This is something that no other relationship models in Drupal supports.

How to use

The Learn Relation module screencast series is a good start if you want to learn how to use this module.

Configuring and creating relations

The Relation module provides two blocks that can be used to create relations. It's very simple and effective. It can also be done using Rules.

Listing relations

The Relation module has a very effective Views integration, both functionality wise and performance wise.

Other cool/crazy stuff

The future

Drupal (core and contrib) maintains too many different (inefficient) relation models (node authors, node comments, comment replies, entity references etc.). The goal is to replace them all with Relation module.

Credits

Credit goes to all the maintainers for building the module and to Itangalo for creating screencast documentation for this module. ITV started sponsoring chx's work on relation on December 6, 2011.

Rationale

While a similar module could be built based on Entityreference and Entity Construction Kit (ECK) by creating a custom entity and adding entity reference fields to it, this hypothetical module would not be able to

  1. refer different kinds of entities for one endpoint
  2. handle symmetrical relations in one API (for eg. a single rule can be fired for both ends of the relationship)
  3. list siblings with Views

Also, relation, while very capable, is a small module which works with many contrib modules but requires none. We keep the API module as small as possible, adding new features into submodules as much as possible.

Downloads

Recommended releases

Version Downloads Date Links
7.x-1.0-beta3 tar.gz (42.59 KB) | zip (56.22 KB) 2011-Nov-14 Notes

Development releases

Version Downloads Date Links
7.x-1.x-dev tar.gz (47.21 KB) | zip (61.58 KB) 2012-Feb-20 Notes

Project Information


Maintainers for Relation

  • chx - 215 commits
    last: 3 hours ago, first: 46 weeks ago
  • naught101 - 166 commits
    last: 3 weeks ago, first: 1 year ago
  • Letharion - 13 commits
    last: 21 weeks ago, first: 41 weeks ago
  • rump - 4 commits
    last: 22 weeks ago, first: 32 weeks ago
  • dixon_ - 30 commits
    last: 32 weeks ago, first: 41 weeks ago

Issues for Relation

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Oldest open issue: 6 Feb 11
nobody click here