List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 25 2000 1:52am
Subject:Re: Keys - Primary/unique
View as plain text  
At 5:23 PM -0700 2000-04-24, Rajesh Krishna Murthy wrote:
>Hi all,
>  I want to know is there any way in a single table can i have two
>combination of composite
>  primary keys which is supported in most RDBMS. So that uniquenss is mainted
>between only
>  those combinations. If this option is not avaliable then i should think
>about have primary
>  key for one and unique for other one . By the way if first option is not
>possible could someone
>  could sent me an example of having primary and unique columns on same

Sounds like all you're looking for is a PRIMARY KEY or UNIQUE index
comprising multiple columns.  Yes, you can do that.  Here's
an example:

     student_id INT UNSIGNED NOT NULL,
     date DATE NOT NULL,
     PRIMARY KEY (student_id, date)

This table records student absences.  Presumably each student can
be absent on different days, and for each date there might be multiple
students absent. So neither of those columns in themselves are unique.
But no student should be counted absent more than once on a given
day, so the student/date combination is unique.

Paul DuBois, paul@stripped
Keys - Primary/uniqueRajesh Krishna Murthy25 Apr
Re: Keys - Primary/uniquePaul DuBois25 Apr
RE: Keys - Primary/uniqueRajesh Krishna Murthy25 Apr
Re: Keys - Primary/uniqueThimble Smith25 Apr