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. (Still, using Relation with anything but the default SQL storage will not work in most cases.)
John, Jen and Jack are siblings. This relation are symmetrical and points in all directions.
Are siblings --|-- Jen
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 from NodeOne is a good start if you want to learn how to use this module:
- Introduction to Relation
- Creating a Simple Relation Type
- The Relation Widget
- Directional Fields and Fields on Relations
- Relation and Views - Part 1
- Details of Duplicate Rows
- More Relations and Views
- Using Relation with Rules
- Creating Relations with Rules, Part 2
- The Relation Add Block
- Relation Select
Configuring and creating relations
The Relation module itself provides a block that can be used to create relations. It's very simple and effective. It can also be done using Rules.
The Relation module has a very effective Views integration, both functionality wise and performance wise.
- The Relation Add module provides a field that can be used to add or edit the relations from within the node/entity edit forms. It also provides a block to manage relations. Relation Add Block screencast
- Create relations from the node form with Relation Select, also with a screencast.
- For extra relation creation constraints, check out Relation Unique.
- Another nice UI is Relation Wizard UI.
- Maintain relations and related content by Relation edit widget
- Connect logged in user and viewed any entity by Relation Sign me field formatter
- Relation Autoconnect provides widget for creation form that connects new entity with another specified in path arguments.
- Relation dialog allows target entities to be created while creating relations.
- Create graphs of all relations on your site with Graph API.
Projects using Relation
- RedHen is a native drupal CRM. Relationships between CRM entities (e.g. contacts and organisations).
- ERPAL is a full Drupal distribution aiming to manage almost any business related processes in service and project based companies, and includes a CRM, as well as management for projects, documents, employment, and invoices.
- CRM Core provides a basic framework for managing contacts, activities and relationships within your Drupal website.
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.
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
- refer different kinds of entities for one endpoint
- handle symmetrical relations in one API (for eg. a single rule can be fired for both ends of the relationship)
- list siblings with Views
- support revisions
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.