I promised I would try and figure this out today, and I thought by making documentation I could understand it better, and then make a contribution.

Along the way, I have made many screenshots and come up with many questions which I'll begin to add.

I'm going to reply to this post and put in a draft tutorial. I clearly don't think I grok this module yet still, but maybe someone can pitch in?

Comments

heather’s picture

Case: We have parent
pages, which manually link to specific child articles.

I chose parent/child because it has the notion of a relationship
built in, should I pick a different kind of example? For example,
a "City Guide" with highlighted travel articles (could also be
reviews, or hotels, etc). Should I call the relation "related articles"?

Entity relation type 	= SUBJECT	+ PREDICATE 		+ OBJECT 
Node author relation 	= node 		+ creator 		+ user 
Taxonomy field relation	= blog post 	+ is tagged with 	+ some term 
Example case relation 	= page 		+ is parent of 		+ articles

Tutorial

Step 1. Enable the Relation modules (Relation, Relation block,
and Relation Dummy field).

Step 2. Next, place the "Relation block/Relation Dropzone block"
in a sidebar, or somewhere accessible from all pages on your site.

Step 3. Define a relation. Example, "parent".

Go to Structure > Relation > Click + Add.

  • Describe what kind of relation it is: directional, transitive,
    unique. In this case, transitive. (Not sure what to pick in this
    case!)
  • Select which bundle types are available as a source (such as
    children). In this case, Articles.
  • Select which bundle types are available as a target (such as
    the parents). In this case, Pages.
  • Save configuration.

A relation can have fields attached to it, however our case doesn't
require fields.

Step 4. Next, collect entities to create a relationship.

  • Visit the front page, which should have a list of several
    entities to "pick an entity". Use the dropdown menu to select
    which entity, an Article in this case, and click Pick.
  • Next, visit the target page, and click Pick.

You will now see two entities listed, the article you picked,
and the page you picked.

https://skitch.com/heatherjames/fya4e/create-relation

Only local images are allowed. src="https://img.skitch.com/20110522-tiyj5gn9i8xurbyq2r2xmfssn7.jpg"
alt="Create relation" />

  • Type in the name of the "predicate", in this case Parent. The
    type-ahead feature will show the possible relations.
  • Click "Create relation"

You will get a message that a relation has been created, and you
can visit the relation page. From there you can delete the
individual relation. You cannot edit relations, to change it, you
must delete and re-create it.

Next steps:

What can a site builder do with relations?

This... I haven't figured out yet :)

naught101’s picture

Step 3: that's a relation type you're creating there, not a relation.
transitivity isn't working yet. directionality is only partly working, but your parent relation is definitely directional (although you need to specify "has Parent" or "Parent of", as they are opposite directions). If you use directional, I think you need to pick the "from" part of the relation first.
You may as well make it unique, there's no instance that I can think of where you'd want a duplicated parent relation.
Your parent relation type could have fields, if you wanted to make the tutorial more detailed, eg: type: select with "biological", "step", "foster", etc.

You can edit fields on a relation, just not the endpoints of the relation.

Nice start, though I think you'll probably have to go into more detail in some parts (especially the hard to grok parts). Feel free to ask as many questions as you need, and I'll answer with as much detail as I can.

RonP’s picture

Naught it would be interesting to see what comments you could add to the document itself.

Can I suggest copy/pasting it and adding thoughts in brackets for the fine person to edit clearly.

As it stands I think I may need to use the other project as I don't understand the lingo in the module nor the description.

naught101’s picture

Isn't that what I just did? I can't edit Heather's comments...

If you have specific questions, feel free to ask, but please make sure you've read all of the documentation in the module, especially the CONCEPTS.txt and the README: http://drupalcode.org/project/relation.git/tree/refs/heads/7.x-1.x

heather’s picture

heya!

sorry I have been plowing away on a big project I am testing next week. i plan to dig into my d.o threads after june 15th.

i will read all relevant documentation before making any new contributions to make sure i'm not duplicating effort.

thanks for the tip!

hlynn1’s picture

[I started this in the #1165292: Clarify the UI text for relationship types thread before I realized it should probably go here instead...]

Not to reopen the can of worms, but for the entity relationship newbies among us, it might help to compare what it means when "directional" and "transitive" are true, and what it means when they're false. Here's one crack at it:

  1. Directional

    Consider the Smiths, a family of five: Mom and Dad, kids John, Jenny and Jeff, and Bill the frog.

    When Directional is checked (true), the relation only goes one way:
    For a directional relation, like is_parent, Mom can be John's parent, but John can't be Mom's parent.
    When Directional is not checked (false), the relation is two-way:
    For a relation that isn't directional, like is_sibling, Jenny can be Jeff's sibling, and Jeff can be Jenny's sibling.
  2. Transitive

    Let's say John is Bill the frog's owner, by the relation has_pet: John > has_pet > Bill
    Now let's consider the transitive property using the relation has_member: Smith Family > has_member > John

    When Transitive is checked (true), the subject can be passed through subsequent relations to apply to other objects:
    In this case, Bill the frog is a member of the Smith Family — John's membership in the family via the transitive has_member relation is conveyed by John to Bill the frog through the has_pet relation.
    When Transitive is not checked (false), the relation is self-contained:
    John is still Bill's owner through the has_pet relation, but membership in the family stops with Bill at the has_member relation because it is not transitive — In this case, Bill the frog is not a member of the Smith Family.

Thoughts? Do I even have it right?

kirkilj’s picture

From my understanding of a transitive relation, your example would not hold. I always thought that in a transitive relation, the relation_type had to be the same. How would Drupal know that has-pet is functionally equivalent to has-member? I don't recall hearing anything about the Relation project going to this length this early in its evolution. It could be done, but it might complicate the queries a bit. It would be cool if it did. I'm a Drupal newbie, so I'm just speculating on any implementation details.

If the relation_types are the same, then the implied transitivity is easy for a query to determine.

If you used grandparent, parent, child, then you could say that the has-ancestor or has-descendant were transitive.

My thoughts anyway.

naught101’s picture

kirkilj is correct. Transitivity only Applies to relations that are of the same type.

I also agree that it's possible that there's a good reason to allow transitivity between relations of certain types, but that will be fairly complicated, and will need a separate feature request. I think many would argue that the example given, that Bill is a member of the Smith Family, is not true. A potentially better use-case is the simple inequality: A<B; B<=C implies A<C, but I don't know whether something like that would actually be useful on a CMS.

naught101’s picture

Status: Active » Fixed

Heather, is that enough feedback? if no, feel free to re-open.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.