Home All Groups Group Topic Archive Search About

PrimaryKey and unique

Author
21 Mar 2006 3:24 PM
Michael Haberichter
how can I design a table to get unique values in a column within the PK
columns?
Example:
Client (int, PK)
User (int, PK
Userid(char...)

userid's shoud be unique for a client. Other clients are allowed to have
same userid's as other clients. A second user of a client cannot have the
same userid as other user of this client.

thanks for any help.

Author
21 Mar 2006 4:01 PM
Tom Moreau
Looks like you have it almost right:

alter table MyTable
add
    constraint PK_MyTable primary key (ClientID, UserID)

--
   Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON   Canada
www.pinpub.com
..
"Michael Haberichter" <Haberichter@community.nospam> wrote in message
news:ED15E772-0327-4C98-8FBD-92AE3717D1FB@microsoft.com...
how can I design a table to get unique values in a column within the PK
columns?
Example:
Client (int, PK)
User (int, PK
Userid(char...)

userid's shoud be unique for a client. Other clients are allowed to have
same userid's as other clients. A second user of a client cannot have the
same userid as other user of this client.

thanks for any help.

Bookmark and Share