Skip to Content

Drupal has some (entity) relationship issues

With entities Drupal took a huge step forward in providing conceptual clarity in how it deals with things like users, comments, taxonomy terms and nodes.

I believe there is one more step to take to bring even more clarity that will hopefully be possible in Drupal 8. This is the content of my Core Developer Summit lightning talk- hopefully it is not completely off the mark.

With entities Drupal took a huge step forward in providing conceptual clarity in how it deals with things like users, comments, taxonomy terms and nodes.

I believe there is one more step to take to bring even more clarity that will hopefully be possible in Drupal 8 (or 9!). This is the content of my Core Developer Summit lightning talk- hopefully it is not completely off the mark.

It goes something like this:

Entities have abstracted (at least conceptually if not completely at the code level) the task of dealing (loading, reading, querying) with things that you can attach fields to. Drupal is now a composition of these Entities into an architecture that creates a content management system with users, nodes for content, comment, tags, etc. This architecture describes the relationships between entities and their implications.

However this architecture is not transparent. It is spread all over the code. It is Drupal. You cannot change it in an architecturally clean way.

I think we are a step away of being able to not just have one Drupal but many Drupals. What is takes is to make explicit the relationships between entities.

What are relationships?

Consider this:

Entity A is a comment to Entity B
A comment relationship is when a Main Entity is discussed by a Secondary Entity and it is displayed either below or in an associated page to the Main Entity

Entity A is a taxonomy term to Entity B
A taxonomy term relationship is when a Main entity is annotated by a Secondary entity and is (typically) displayed below the Main entity

Entity A is following Entity B
following is when one Entity is notified of activities performed by/to another Entity

Entity A is a friend with Entity B
Friend relationships are when both Entities are notified of activities performed by each one

So relationships are just what meaning we decide to give a certain word like comment, taxonomy term, follows, friends together with some logic about what to do when the relationship exists and how to represent it.

If we actually represent this in code by having an explicit Relationship concept with it's associate type and logic building Drupal website then becomes:

1. Define entities
2. Define relationships between entities
3. Build views

This is much better than the situation today where we have content types with some fixed relationships to things like comments and terms but then we also have nodereference and userreference in order to build out other relationships to users and / or other nodes.

It all comes under one conceptual roof and changes the nature of what Drupal is. Drupal is the system that manages all of this and can re-create Drupal as we know it today with nodes, terms, etc but it can also do other Drupals. It makes the architecture of the CMS clear and separate from the other stuff and this means that we can then manipulate it.

A note: this is not about what the end user sees. They don't need to know anything about this. This may not even be about what your everyday developer / site builder sees either as they may well only ever be at the level of a specific entity + relationships architecture.

This is for the people that really get into the bowels of what makes Drupal Drupal and should give them a change to change that.

Another note: This is here so that it is discussed - it is not fully thought out yet. The main point is - should we make the relationships between entities explicit? And if we do that would that provide us with significant expressive power to do more?

This attached PDF says all this in slide form.

Ronald's Blog - click for more info about me


Live and work in Sicily with my wonderful daughter and amazing wife (who, among other things, runs a great Italian cookery school) and have been a Drupalista for a few years now.

Interested in decentralised networks and semantic web technologies - goes back to my PhD and subsequent research work at Southampton University where I developed means to model agent-based systems and the relationships between the various components.

I think Drupal (and systems like it) can play a huge role in making the web a more decentralised and interesting place and that is what gets me going. The fact that Drupal also makes it possible to live and enjoy life just 5 minutes from the Mediterannean sea is a huge bonus!

You can follow me on Twitter @ronald_istos while my Drupal page is here.


there is already some awesomeness

agreed.

Drupal 7 is the time for this to be hashed out in the contrib laboratory. I also spoke about this very topic at the DCSF Core Developer Summit. See https://docs.google.com/present/view?id=dd5cppm9_107hnqrxwdq The title is a bit sensational, but it points to the need to stop constraining the relationship data storage by the type of entity it's pointing to. I kinda also want to see terms go away and focus taxonomy module on vocabulary authoring and relationship modeling for all content.

There are other tasks that I have in mind that will let us dislodge some old-fashioned stuff in Drupal. In particular, we need to replace the parent term field in Taxonomy module with a modern Field API field.

I also want Drupal to be agnostic about relationships among local data entities and remote data entities.

Check out Awesome Relationship module (chx linked it above). See the README file for some of our concepts behind it. If you have ideas, please contribute! I think we are on the same wavelength about this.

agree, but...

I like in principle where this leads. However, I think this kind of change needs to start from the underlying data store (or, in other words, no abstraction layer is powerful enough to compensate for the impedance mismatch). I will keep watching with interest.

Thank goodness this is

Thank goodness this is finally happening, it's sure taken long enough

Zope

How does this compare to the ZODB (Zope Object Database)?

RDF?

What you describe leads directly to RDF tuples. The concepts have been there forever. The performance has never been there. That's always been the problem. :-)

exactly..

Larry - what I described is implementation agnostic (I don't go much further than talk about fields and NOT entities) - performance is part of the reason (although I haven't worked out all the implications) the other part is conceptual clarity. The AwesomeRelationships approach goes the Relationship is an entity route and it will be interesting to see how far that can take things

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.