Adcade
5 months ago

Many to many relationship with roles

Posted 5 months ago by Adcade

I have the tables users, communities and community_user

community
    id
    ... (other columns)

user
    id
    ... (other columns)

community_user
    id
    community_id
    user_id
    role

I want to create relationships so an user can belong to many communities and have a different role on each one (admin, member, etc).

How should I define my models? Can a many-to-many relationship have a key?

Please sign in or create an account to participate in this conversation.