How to relate entities - users with multiple roles

1.6k views Asked by At

I have 3 entities to represent Users, Roles and Conferences So far I got this diagram: Entities

So,

-A user can be associated with zero or more conferences.

-A conference may have one or more users.

and...

-The same user can have different roles depending on which conference he is.

but...

-How can I improve the diagram so i can see the different roles of a user in all the conferences he has attended?

[UPDATE]

NEW DIAGRAM

1

There are 1 answers

1
Aaron Palmer On BEST ANSWER

From your description it sounds like users belong to roles, and then the combination of userRoles belongs to a conference. So, without the fancy diagram, your entities would be something like this...

Users
    Id

Roles
    Id

Conferences
    Id

UserRoles
    UserId
    RoleId

ConferenceUserRoles
    ConferenceId
    UserId
    RoleId

You may need to add a "UserRoleId" to UserRoles and use that in ConferenceUserRoles. I'm not exactly sure how EF will handle the three-way relation table.

Hope this helps!