mfbrc2i_0.jpg

Overview of Entity Reference

Tuesday, October 11, 2011 - 11:53

This blog post compares the Entity Reference module with the more complex Relation module and the "old-style" References module.

If you haven't tried the Entity Reference module, you should. It is quick and easy to get started with, does (almost) everything that the old Node reference and User reference does, and is generally just slick to work with.

If you haven't been offline for the last few months, you probably know that Entity Reference shouldn't only be compared to References, but also to the Relation module – the all-in-one solution for any crazy information relationships you'd want to create on your site. Here's a quick comparison between the modules. I hope it can be of some help.

Short-short version: Use Entity Reference if you have simple relations, going from one entity to another and doesn't need any extra information or anything. Use Relation if you need more complex relations.

Long version

The descriptions below are written with References (Node/User reference) as starting point, describing what you get if you switch module.

  • Benefits of Entity Reference: Can reference any type of entity. Easy to implement – follows same patterns as Node/User reference. Has Views integration, even for reverse relationships. Has Entity API integration, so it works well with Search API and Rules.
  • Benefits of Relation: Can reference any entity type, and even different types in the same relation. Stores relations in external entities, allowing (a) adding fields to relations, (b) having revision control of relations, and (c) symmetrical relations – no specified start/end point. Has Views integration even for reverse relationships. Drawbacks: Takes more time to set up. Has a slight performance impact.
  • Benefits of sticking with References: Still the only of these modules where you can limit the selectable items with a View. (As far as I know – please correct me if I'm wrong!) Still the only module that integrates with Page manager's context system.

If you're interested in seeing Entity Reference in action, you can check out these four screencasts:

  1. About the Entity Reference module
  2. Settings for Entity Reference fields
  3. Using Entity Reference in Views
  4. Using Entity Reference in Rules

Attachment

application-octet-stream_30.png