Re: Primary Keys and Foreign Keys

From: Marshall Spight <mspight_at_dnai.com>
Date: Mon, 14 Apr 2003 15:18:51 GMT
Message-ID: <vjAma.477290$S_4.534068_at_rwcrnsc53>


"David" <no_at_e-mail.com> wrote in message news:3e9a76b4$0$958$cc9e4d1f_at_news.dial.pipex.com...
>
> Thanks for your help. You're two replies have slightly confused me.
> If I define a composite Primary key in Lives (Person_ID,House_ID) is there
> any need to set a foriegn key in the other tables?
> If a foreign key needs to be set, it is correct to define House_ID in House
> and Person_ID in Person as a Primary Key AND foreign key to reference the
> composite primary key in Lives?

No, you've got it backwards. House_ID is a foreign key in *Lives* referencing the primary key in House; Person_ID is a foreign key in Lives referencing the primary key in Person. (Person_ID, House_ID) is the primary key of Lives.

Or as Bert said:

> "Bert Blink" <bblink_at_pcug.org.au> wrote in message
> news:p43k9v03h6fh5tkhrn2b7trv9i1reuhh1k_at_4ax.com...
> > >
> > >No the other way round Person_ID as a foreign key in Lives referencing
> > >Person & House_ID as a foreign key in Lives referencing House.

Marshall Received on Mon Apr 14 2003 - 17:18:51 CEST

Original text of this message