06
Apr

Drupal Relation Module

06 Apr

Recently I started working with Drupal Relation module, which is quite an interesting module. 

What is Drupal Relation module?

Basically, it`s a way to manage things like node references and user references in Drupal 7. The module provides an API and a basic user interface.
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.

What type of relations can be created?

Different types of relations can be set up, depending on your needs these can contain different information and can be used for different purposes.

For example:        EmployeeA   -->  Department  --> Company
                                (user)             (relation)            (node)
Here we have a relation between Employee (user) who works in a Department that belongs to a Company (node). This is a directional relation.
You need at least one relation type to use the relation module.

Can I integrate the Relation module with other Drupal modules?

Yes! 
Relation can be integrated with Views, Rules, Feeds modules.

Integration with Views allows you to add relationships between (entity <-> entity) or (entity <-> relation). The first will join data from the endpoints in the relation – which is usually what you want to do with Views. Using this relationship you will, similarly to how node reference or user reference works, get data about other objects in the relation.

Relation module is an interesting module which, if well understood, can be a powerful tool for a Drupal environment.

Leave A Comment