sql - Primary key and composite unique index behavior -


i'm doing little custom membership system , i'm having issues. have these tables (users, roles, applications, membership).

i want this:

users

|userid | applicationid | username | ... |1      | 1             | abc      | ... |1      | 2             | abcd     | ... 

"is same user in several apps, despite different username"

roles

|roleid | applicationid | rolename | ... |1      | 1             | xxx      | ... |1      | 2             | xxx      | ... 

"is same role in several apps"

with userid/roleid primary key , userid/roleid-applicationid composite unique index know system won't allow me create user in 2 applications.

i tried composite primary keys head ache after make correct fks because membership table needs recognize application (one user can have several credentials several apps).

what best way do, if possible?


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -