Re: Creating a table with two keys?

From: P.W. Milo <pmilo_at_orca.nl>
Date: 1996/10/28
Message-ID: <32751E52.6886_at_orca.nl>#1/1


Brian Master wrote:
>
> I know this is probably a simple question, but how do I create a table
> with two primary keys? Here is what I tried, but it doesn't work:
>
> create table class
> (
> semester_code char(3) not null primary key,
> course_num smallint not null primary key,
> hours float not null
> )
>
> Thanks for any help,
>
> Brian Master
Brian,

The best solution here is to create one primary-key constraint and one unique-key constraint. If you can't decide on a primary-key, although in relational theory a table should have a primary-key, you can create two unique-key constraints.
You can reference a unique-key constraint in a foreign key constraint.

P.W. Milo
ORCA Solutions BV. Received on Mon Oct 28 1996 - 00:00:00 CET

Original text of this message