sql - Multiple roles to single user -
i want design schema sql database in user can have multiple roles admin,tester, developer , have accessibility module(test,develop,performance) per role. tried design 3 tables first of users in user have id , role id,second 1 of role ,and third of module have foreign key of user , role in assign permission role.
but fails when user have multiple roles
seems basic many-to-many relationship me - need 3 tables:
2 entity tables , 1 conjunction table.
in case there should user table, role table, , usertorole table.
module / role many many relationship - since many roles might connected single module, , many modules might connected single role.
a basic implementation might :
tbluser ( user_id int primary key, -- other user related columns ) tblrole { role_id int primary key, -- other role related columns } tblusertorole { urt_user int foreign key tbluser, urt_role int foreign key tblrole, primary key (urt_user, urt_role) }
wiki
Comments
Post a Comment