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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -