Free Videos about Mastering Views

How To: Using View's Relationships

Play Video
Movie link (right-click to download)
Problem with this video? Contact me

Using View’s Relationships is quite simply a matter of knowing how “one piece of content relates to another”. If you can wrap your head around this simple concept, then all your complex Drupal views will be realized quickly.

The most common use of Views relationships will center around content types which utilize some form of “reference” field type. This will likely be either User references or Node references - but won’t be limited to these field types for use in Views relationships.

Understanding how the data is stored within the Drupal database is also a big help to achieving your goals.

If you start with the data and relationships in mind first, then arriving at your ultimate goal will become much easier.

This video will showcase the use of Views Relationships in a very simple fashion. Using an example of a Department/Employee directory, we can “relate” a Department content type to the User table within a Drupal View.

Moving on from this point is simply a matter of creating more relationships. In fact, watch the video, then take this task upon yourself. Create a view which will output a Department > Teams > Employees listing and you’ll have an excellent start with Views Relationships.

Here’s a link to any earlier video by Andrew Morton, which I reference at the beginning of this video.

Excellence, clearly explain what we need to know... thanks

I have watched each of your videos and I think this might be my favorite! Thanks for spending so much time and energy producing these excellent tutorials.

If you are taking requests it would be great to see more on views, particularly the relationships with relationships and advanced theming you mentioned toward the end of this lesson.


Your vedio help me a lot ,thanks! I'm your fans

Hi Matt,

this is a great video--and brings me so close to what I'm trying to do!

Can you tell me if I'm missing something & just need to re-watch it?

I'm just trying to have a view (in a block) which displays a node if it's Taxonomy Term matches the Term used in the main content of that page. It seems insanely complicated though. It must be done via Relationship, right?

Without more of the details, it sounds like you might need to use Views Arguments. The Relationships feature allows you to connect two (or more) different tables in the Drupal database. This would fit your need to connect content types to taxonomy terms.

If you're wanting to show a block, then I'm assuming you want a block that is relevant (contextually) based on what is being currently viewed - a specific taxonomy term? This can be done when you are looking at a specific node or a listing of nodes based on a taxonomy term, but not when looking at the front page (which may be a collection of many different content types [i.e. nodes]).

There's likely a module which can do what you want if you want to show other related content based on the context of where the user is at.

Here's a module which I've been looking at lately (and will probably do a video about) Views Attach. This module essentially attaches a view to the bottom or top of a node where you can use information from that node (such as a taxonomy term) to derive related content - I think.

However, this still doesn't help you get it done using a block. After all this, the best I can offer via this forum is "What you want to do, can likely be accomplished." It's just the matter of the time you have to invest to find out how to make it happen.

Much luck! - Matt

For this another great video, it's very clear!

I just love your style. Clear, precise, just useful as hell.

Many many thanks.

First, this is a nicely done video that builds and supplements that of Andrew Morton's work.
Second, I really like the emphasis on the reference type being required. That's the key and I hadn't heard or seen it presented in this format before. I quickly wrote that point down in my note keeping blog for reference.
Third, the name Matt Petrowsky made me look at my bookshelf. Are you the same Matt Petrowsky with a past in FMP?

I'm off to look at some of your other videos.


Nicely done. well paced and explained. made a lot sense. Thanks!

Great job in the views screen cast. This is a big subject when developing any site. I am just a beginning but love to tinker with Drupal.

Check out my simple site at and provide comments. I am just beginning to develop the site and only post what I think will be useful for everyone.

Hi Matt, I've enjoyed watching your videos lately and they've been a great help. I was wondering if you could give me some brief guidance as Im not sure if I can achieve what I need using relationships.

I basically have a customer CCK node, and also a "medical prescription" node - users can have multiple prescriptions and I need to setup a view so you can see the customers name (which is a cck field in the customer node) and any relating medication notes (from the prescription node) - so its basically joining the two cck nodes together to give a mixed number of fields in the resulting view.

Should I use relationships for this? I'll be grateful even for a one word reply :)

Cheers, Garry.

Just to clarify, if I have two different node content types (artist & artwork) that are connected through a node reference, I would use arguments not relationships because the table is the same for both?

thank you for the excellent work!

Mat Thankyou, thankyou.

That was really, really useful. Beats reading 100 pages is text.

A request.

Could you outline howto use quicktabs.

More specifically create something like a joomla / community builder profile page which contains tabs?

Thanks in advance.


You just helped me understand and solution something that I've been struggling with for hours.


Thanks for the great helps a lot, but one thing is missing for me.
How do you add a user to a department? Or do you just go to department/edit and click all users belong to that department?


Thank you very much Matt for taking the time to make such an excellent teaching video. Like many others I was searching to find a clear grown-up explanation of how to use the Relationships feature of Drupal's Views2 module. This more than does the trick. There are many abandoned threads on that could use a link to this video. I intend to add a link to such threads that I've come across in return for my newly found clarity. :-)

Thanks again...

Drupal Rocks!!

Derek G

Exactly what I was looking for

Your vedio help me a lot ,thanks! I'm your fans
from vodoleq


Right now I'm using Views Bulk Operations (VBO) to change the item_id on my "Item details" table to the one gathered from "Items". The relationship between both contents is one ("Items") to many ("Item details").

The only relationship between both tables is done by the CCK TextField item_id ("Item details" table having multiple rows per one row in "Items" table) but that doesn't satisfy the node reference that has to link to a Node id (nid) on the other table. The node reference works only if the item_id on the Item details content type (or table) is able to gather the nid (Node id) from the related item_id in the Items content type.

But being that Drupal is a CMS I would want to simply relate the item_id CCK field from one content to the other without so much effort (that is, I could declare item_id as a Key field and Drupal creates the relationship with a node reference by its own) and I think I'm missing the point on how to achieve this easily so we can later use Views Relationships later and create a nice table with both data related.

Hope this makes sense.

Thank you!

this guy loves the sound of his voice way way too much. I stopped the video when it had played for 4 minutes and he hadn't covered a d*** thing!

Thank you for putting this info together as a video, though I did find it to be a bit unclear in the explanation. Here is a link to a fairly straight forward setup: Installation and Setup for Node Reference View.

Hi Matt,
Very good video thank you so much! I have just one question: you decided to add an employees field in the department content type. Does it mean that when you create content for a new department, you will have a field named "employees"? If yes, is this not a problem? (I don't want to add a new content department for each employee belonging to a department). Wouldn't be more correct to change the point of view from department to employee and add a department field in an employee content type node?

In fact, I'm convinced that learning how to organize and structure data is something that only comes over time and practice.

You're exactly right, you can structure things that way. For anyone who is watching these videos and thinking there is only one "right" way of doing things - you can stop right there and tell yourself to keep seeking more knowledge. There's always more to learn and as soon as your current structure doesn't work for what you want to do, you get to tell yourself "Well, I learned that lesson, now I know that much more about how data can be structured differently". Much luck with all your projects!


At long last my old school days of crafting SQL by hand is starting to sync with using the Views module. Thanks for the clear explanation of using JOINs (relationships). Your efforts are very appreciated, thanks to your hard work and making it very accessible the challenging learning curb behind Drupal is a little easier.

Hey Matt,

Thanks for posting a great series, and this one does explain the relationship in Views very clearly.
I'd be very interested in the follow up video, explaining Relationships based on Relationships.

The example I am currently working on uses Content Profile CCK fields.
I'm wanting to display the Organization, Phone, etc. for the Author of the Node.

Thanks in advance, and I will have to buy you a beer at Devcon 2010 !

I'm also interested to know how to make a relationship based on relationship. Can you give us some tips ?
Thanks for your video.

Thanks a lot for the great video. Your way of presenting complex topics in a structured clear way without "uhms" and "ahs" is a pleasure to watch. If only 10% of the screencasts I saw elsewhere are as good as this. I have been familiar with SQL and JOINs and suddenly relationships became so obvious that I wondered what I missed from the documentation. Getting to know Drupal is one half of the job. Views and Panels are the other half. You really helped. Keep on the good work!

What if you wanted to do this the other way around display a list of uses and what department they work in. (keeping the same node reference).

Thanks for a great video!

Hi Matt,

I'll just start by saying thanks for the videos. They really are very good indeed.

So I followed your video tutorial but for some reason when I choose to group the fields by Departments as set in the Style:table setting it displays a department for each user and also seems to add a second 'Department' title inbetween the rows? I've been back through your tut a few times and I can't see what I've done different. I've put a screen shot here in case you get the time to have a look.

Many thanks

Fantastic video. I'm a MOSS 2007 developer (among other things) and I hate how their Custom Lists are really tough to make worthwhile relationships between each-other and are a real pain to do anything with in a reasonable amount of time. This looks great, and, while researching Drupal this was one of the first things that was a must, how do content types relate to eachother and the efforts to create views of those relationships. I would love to see something on how to style those views as well.

Halfway through the video I had a 'Eureka!' moment and went to my site and made the relationship fix that had been my obstacle for over a week. Thanks very much for this useful video. Views2 really is as powerful as they say, and this video makes obvious the otherwise unintuitive aspect of relationships in views.

I think this is the best video tutorial for me during this year! It helped me a lot.

Thanks Matt!

Great video, really clear and precise. I have a question: using your example, how would I go about creating a view that referenced the data the other way around? That is, can I create a view based on a user, then create a relationship to the department that contained a reference to that user?

I'm building a database of houses in a small town. Each house had a number of families that occupied the house. I have created 3 content types: "house", "family" and "tenancy". The tenancy content type has node reference fields to the house and family, and date fields for when they moved in & out.

I want to create a view that shows info on a particular house (by address). The view should show general house info, plus info on any tenancies (family info, when they moved in etc). I can build a view based on the "tenancy" content type, and pull in "house" and "family" data via relationships, but the problem with this approach is that no house information is returned if no tenancy data exists, as is the case for several houses.

Is there a way of using views relationships to join a node to another node that references that node, rather than the other way around?

Sorry if my question is long-winded, but I'd rather give too much information than not enough. Thanks in advance!


Just what I needed to know for my location field problems. The whole relationships thing seems like it could be a bit more user-friendly, but given the complexity of the software, I can't complain too much.

Many of the commentators on the site compliment your clarity. I could not disagree with them more.

You speak in ultra-long complex sentences with unnecessary clauses. Then just to make things harder to follow you add random asides in the middle of your sentences. By the time you have finished saying something I have forgotten the subject.

Also, you add an exception or caveat at the end of every rule. Tell us about those at the end of the video. It is a much better information flow technique.

Also try to pace the complexity a little more evenly. Often in your videos, not this one specifically though, you ratchet up the complexity suddenly and abruptly. I was watching your video on views arguments, and you were explaining the arguments in a slow voice. Next thing I knew, you were talking about how they would integrate variable url-argument passing into Drupal 7's menu systems, and you had a a text editor open with code everywhere.

There should be a gradual methodology for incrementing the complexity of the videos on your site; like beginner, intermediate, advanced.

Otherwise, thank you for all the effort you put into these!

What if you want to include some information about each department in the view, like a description of its function or location? The "grouping by" option only displays the department name.

This was a lifesaver! I was about to give up hope on getting my view to show fields from a different node type. Your comments about the importance of how you approach the relationship (from what perspective) hit home. I realized that I had included my node reference field in the wrong node type in order to do what I wanted. As soon as I added this field to the node from whose perspective I was viewing the relationship, it worked perfectly!

Thank you again!


This tutorial helped so much! Thank you!!!!

However, is there a way for the users to display the department it belongs to? Instead of the departments showing the users that belong to itself?

So basically just flip around the labels.... is there a way to do that?

thank you!


I want to thank the author of this excellent teaching Video, at the same time like to ask him : Is there a prerequisite video that one must see before this one. I feel that there is one because the video is mentioning things about departments and employees which I feel were mentioned before in another video?

I came here for solving a Scenario hardly explained at

I at last did it with arguments passed from viewfield to view. I think it will be nice if you can make a tutorial for arguments also.

Keep Rocking!!