I an adding entity references to an existing site with a lot of data, and I want to make sure I get it right first time. My question is - is it best practice to put an entity reference in the container content type, or in the contained content type? In other words, is it best practice for the entity reference to be in the album content type, or the track content type (also applies to team/team member, book/chapter or whatever)?

In an ideal world these relationships would be in both content types, but that doesn't seem to be built-in and the relevant module (Corresponding Entity Reference) seems to be in Alpha. So what is best-practice?


Where you definitely have a 'container' vs 'contained' relationship, I would say the best way to go is to put the reference field on the contained field. If you put the reference field on the container then every time you make a new item to be contained you have to edit the container as well.

Frequently I find that 'containers' end up with many more child objects than were originally intended, putting the reference field on the child object helps keep it manageable.

Also, when you are rendering the content or using it in views, you can use the reverse relationship. So if you have books with many pages and each page references the book it belongs to, you could have a view that is based on books but also contains information about the pages. And yes, that is using CER, so far for me it works quite well.

  • Yes, putting it on the contained rather than the container I think is probably the way to go. The only problem is when you have a new container which has lots of pre-existing contained items to contain, all the contained items need to be updated. But either way you're going to hit that kind of problem I guess. – James Mar 23 '15 at 11:25
  • Use Views Bulk Operations to edit the contained items in bulk. – Darvanen Mar 23 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.