Re: Foreign key question

From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Terry Lee Tucker <terry(at)esc1(dot)com>, Victor Spång Arthursson <victor(at)tosti(dot)dk>, pgsql-general(at)postgresql(dot)org
Subject: Re: Foreign key question
Date: 2004-01-15 18:34:32
Message-ID: 1074191672.4006dd3810c12@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mensaje citado por Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Terry Lee Tucker <terry(at)esc1(dot)com> writes:
> > From the HTML docs:
> > "The referenced columns must be the columns of a unique or primary key
> > constraint in the referenced table."
>
> > I personally don't know of a work around. Maybe some of the others do.
>
> There is no workaround, because foreign keys don't make any sense if
> there isn't a uniquely identifiable referenced row.

A better way to understand it is:

Foreign keys are many to one assignments.

Try to think of it as a function (mathematicaly speeking): You can't have an element
from the domain end up on two different elementos of the co-domain.

In simbols:

If f(x) = y and f(x) = z => y = z

Those this bring insight?

P.D.: Aparently you are having problems with your database model.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués | Programador, DBA
Centro de Telemática | Administrador
Universidad Nacional
del Litoral
---------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Terry Lee Tucker 2004-01-15 18:45:38 Re: Foreign key question
Previous Message Bruno Wolff III 2004-01-15 18:21:05 Re: CASE SELECT syntax