| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: foreign vs primary key
On Thu, 20 Sep 2001 09:39:44 +0200, Ewald =?iso-8859-1?Q?B=F6rger?=
<h.a.e.borger_at_student.utwente.nl> wrote:
>mikeg wrote:
>> "Dan Star" <danstar_at_engman-taylor.com> wrote in message
>> news:3ba90b40$0$12824$272ea4a1_at_news.execpc.com...
>> > mikeg wrote:
>> > > I have read a number of texts regarding the terms foreign and primary
>> keys
>> > > but I just can't get a feel for their uses.
>> > > any help appreciated,
>> >
>> > Think of Parent-Child. The foreign key is a key in a table that is the
>> > primary key in another table.
><snip>
>>
>> Thanks, I can see that but what is the significance? Why is it necessary to
>> identify the foreign key? How are they used? Aren't primary keys enough?
>
>Normally: yes, up till yesterday I never bothered (mysql doesn't even
>have support for it)... now I'm going to have an application *guess*
>what columns contain foreign keys 'cause the production database (SQL
>Server) I need to transfer doesn't have explicit foreign keys defined
>(even worse: columns don't even have consequent names :(
>
>
>Ewald
if i understood it, you hava tables like these:
table one a integer b integer c integer table two alfa integer beta integer gamma integer
and you want a program (not yourself) to understand which among a b or c is a foreign key referencing one of the fields in table two ??? i'm afraid itìs a deperate situation.
well, you can have your program compare a great number of elements from table one with elements in table two, so that you can decide which is the couple being fk-pk with highest probability, but you'll never be sure. i'm afraid human are still better than machines at guessing.
let me know how it goes on!
cheers
Roberto Padovani
![]() |
![]() |