ER-Diagram: Ternary Relationship - How to read properly?

前端 未结 3 1360
清酒与你
清酒与你 2021-02-02 15:45

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?

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 16:01

    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.

    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).

提交回复
热议问题