22

Im not quite sure how to read ternary relationships within a ER-Diagram. Lets say this is the ternary relationship that is given. What can I interpret out of that?

account-user-project three-way relation

It says that you have to put your hand on 2 entity sets and then read it like that.

Hand on Account and User: A pair of Account and User can be associated with M projects.

Hand on Account and Project: A pair of Account and Project can be associated with M users.

Hand on Project and User: A pair of Project and User can be associated with 1 Account.

Are the pairs always in a one to one relationship or how many pairs can there be?

3 Answers 3

61

Late answer, but might serve future readers.

Assume the ternary relationship has participating entities A, B and C (for degree > 3 it gets pretty hairy).

The way to read the relationship is to always isolate 2 out of the 3 participating entities and see how they relate towards the third one. And you need to do this for all possible pairs.

More precisely: the 2 entities that you pair each time, need to be considered as "one of" for each one of them and the question to answer is "how many" of the third one can correspond to this pair.

Abstract example

"One of A and one of B can {have/associate with/belong to} X? of C". We need to use our knowledge of our business model to answer if X? should be 1 or N. This is the cardinality to assign to the ternary relationship on the edge that connects the ternary relationship with the entity C.

This phrase has to be reformed for all possible combinations (not permutations, since the order of pairing doesn't matter). So to answer the question How many pairs are there?, simple math dictates that the possible ways to combine 3 things in groups of 2 is:

3!/(2!*(3-2)!) = 3.

So all the possible phrases to answer using our business model are:

  • One of A and one of B can {have/associate with/belong to} ?X? of C
  • One of A and one of C can {have/associate with/belong to} ?Y? of B
  • One of B and one of C can {have/associate with/belong to} ?Z? of A

Specific example

I'm borrowing this image I found online.

enter image description here

The realities of our business model that led to this image are:

  • 1 Physician with 1 specific Patient can log M Treatments
  • 1 Physician logs 1 specific Treatment for N Patients
  • 1 Patient is logged 1 specific Treatment by 1 Physician

So the ternary relationship log is an M-N-1 relationship between the participating entities Treatment-Patient-Physician (in this order).

5
  • Very clear explanation, thanks. For those who are confused between the interchangeability between m and n, they are different variable names for the same concept: the number of objects.
    – arlyon
    Commented Jan 5, 2017 at 8:10
  • When considering pairs, should we consider an actually associated pair or just any pair? Specifically, should we pair "one physician with one patient they have treated…" or "any one physician with any one patient (in the database)…"?
    – Soumya
    Commented Jan 14, 2018 at 12:52
  • 1
    @Soumya Doesn't really matter. We're considering it abstractly, one physician with one patient => how many treatments do they relate to?. Obviously this applies for the case of a physician who treated a patient, which should exist since the relationship connects the two. But the question we seek to answer is how many treatments does the phys-pat couple relate to?. (now, that's a delayed response! :)
    – thalisk
    Commented Mar 18, 2022 at 12:41
  • @ThalisK. in other words you're saying that the meaning of a ternary relationship is ambiguous ?
    – AngryJohn
    Commented Aug 28, 2022 at 17:37
  • 1
    @AngryJohn Not at all. Just that care needs to be taken in reading it correctly. Take all possible pairs as one of each and see how they relate to the third one.
    – thalisk
    Commented Aug 29, 2022 at 19:52
0

Most likely it's a hierarchy and it's means there are many account and many users. It's also means account is smaller or equal to user. It means more users to account. Most likely I use ternary data structure with tries.

0

Another late answer, but might serve future readers. But yes, you're correct @user2276094.

As you mentioned, multiplicities in ternary relationships are devised, by isolating one entity (a target entity) from the 2 other entities, and associating the target entity (say Staff) with a fixed pair of a single occurrence from the 2 other entities (say Client and Branch).

So, you can phrase those multiplicities in the relationship (says Staff register Client at a Branch) as,

For a fixed pair of a Staff occurrence, and a Branch occurrence, there may or may not be Clients (cause some staff may not register clients, they maybe involved in other duties).

For a fixed pair of a Branch occurrence, and a Client occurrence, there must be one and only Staff(cause a Client can be registered only once by one and only Staff member).

For a fixed pair of a Staff occurrence, and a Client occurrence, there must be one and only (assuming Client can be registered only at one branch).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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