Search code examples
umlentity-relationshipsoftware-designerd

Entity Relationship Diagram, generalization when only one class can interact with another class


Let's imagine we have a User class, this is a generalization of two other classes: Admin and noAdmin
There is a another class to which only an Admin can interact with, let's call it only_admin

My question is, to what class should only_admin be related to? User or Admin?

ERD


Solution

  • If User is associated with Something, then, all specializations of User (i.e. Admin and NoAdmin) would be associated with Something as well.

    Therefore, if Something makes only sense with Admin, then make the association with Admin only and not with User. The diagram would be crystal clear and self-explaining.

    Additional remarks:

    • If NoAdmin has nothing specific compared to User, you do not need to have an own class for it.
    • If things get more tricky, and User would have many more specializations, most of them being associated with Something, except a few, or if you'd have SomethingForAdminOnly which would be a specialization of SomethingForAllUsers you could have a look at this other SO question.