Multiple Columns as Primary keys

Posted by rockbala on Stack Overflow See other posts from Stack Overflow or by rockbala
Published on 2010-04-12T23:47:36Z Indexed on 2010/04/12 23:53 UTC
Read the original article Hit count: 548

CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName) )

The above example is taken from w3schools.

From the above example, my understanding is that both P_Id, LastName together represents a Primary Key for the table Persons, correct ?

Another question is why would some one want to use multiple columns as Primary keys instead of a single column ? How many such columns can be used in together as Primary key in a given table ?

Thanks

Balaji S

© Stack Overflow or respective owner

Related posts about primary-key

Related posts about sql-server-2005