Click to See Complete Forum and Search --> : primary keys and composite keys


L0veCraver
05-25-2001, 09:05 PM
Hi

I've got 2 tables one With :

Study(sno, sname, auditorno*, projno*).......sno is primary key

the second table has Task (sno*, duty)

both are primary keys but sno is also a primary key in the study table, how
do i set the correct constraints ?

Create table study(sno primary key
...................sname
...................auditorno references study(sno)
...................projno references project(projno);

would the referencing of auditor no be correct since it is the sno of another
study?

how would reference the second table ?

Paul Mc
05-26-2001, 02:38 AM
G'day.

>Create table study(sno primary key
>...................sname
>...................auditorno references study(sno)
>...................projno references project(projno);
>
>would the referencing of auditor no be correct since it is the sno of another
>study?

Yep that is fine. just remember that this column will need to be nullable
else you will be unable to get the first row in! "8-)

Cheers,
Paul