Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
KenA
Starting Member
28 Posts |
Posted - 2004-06-30 : 18:09:02
|
| In the table below:===========Roles===========UserID (int)GroupID===========Considering that UserID is FK from Users Table and GroupID is FK from Groups Table:===========Groups===========GroupID (int)GroupName======================Users===========UserIDUsernamePasswordEmail===========And considering a User can have 0 or many Roles, exs:Roles table ===========1,11,21,3===========Meaning that this user have roles: 1,2,3The problem is that I can have also:Roles table ===========1,11,11,1===========which is bad, so I need to have a constraint in the Roles table to force GroupID Unique ONLY in case UserID is already there!Is it possible?»»» Ken.A |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-06-30 : 21:47:02
|
| [code]CREATE UNIQUE INDEX UI_UserID_RoleID on Roles(UserID,GroupID)[/code] |
 |
|
|
|
|
|