Relationship between three entities


I have a real case that requires an associative table with three keys, Elgg provides the relationship table that can not link three objects together.

For example : A Proffesor who teaches at several universities, he was assistant in the school 1 department boss in school 2, it has several functions / roles at the same time in many shools.

Here, we have :

Professor -> Assistant -> School 1

Professor 1 -> Boss -> School 2

The prefix_entity_relationships table must contain :

guid_professor1 -> guid_function1 -> guid_shcool1

guid_professor1 -> guid_function2 -> guid_shcool2

or also have

guid_professor2 -> guid_function1 -> guid_shcool1


 contrariwise, if we put :

guid_professor1 -> guid_function1 =>Where the professor 1 occupies the position 1 ? school 1 or shool 2
guid_professor1 -> guid_shcool1 => What position the professor 1 occupies in school 1 ? function 1 or function 2
guid_function1 -> guid_shcool1 => Who professor have the position 1 in school 1 ? professor 1 or an other professor 2

Thank you for your help

  • please don't start duplicate threads, you've already asked this exact question a few days ago.  If you need to ask followup questions continue it in that thread.

    The answer is to either use different relationship names

  • Sorry matt, I think to expand the topic.

    But the answer does not answer exactly the question. The current model can't implement a relation beetwwen more than two entities, In design,ie an associative table with more primary key has a cardinality of 0 .. n

    Thank you