Re: Is cycle references?

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Tod McQuillin <devin(at)spamcop(dot)net>
Cc: limin(at)www(dot)pumpkinnet(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Is cycle references?
Date: 2000-11-07 18:11:55
Message-ID: 200011071811.NAA00968@jupiter.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tod McQuillin wrote:
> On Wed, 1 Nov 2000 limin(at)www(dot)pumpkinnet(dot)com wrote:
>
> > The db schema we have need to do a cycle references. I.e.,
> > an attribute in table_1 references the key in table_2 and
> > an attribute in table_2 references the key in table_1. However,
> > PostgreSQL does not allow us to make reference to an "non-existing" table!
> >
> > Is there any work-around on this issue?
>
> I had the same problem. You can play around with creating the tables
> without the RI checks and adding the constraints later, but I found this
> clumsy.
>
> The solution I used was to have a third table with attributes referencing
> keys from table_1 and table_2. This avoids the problem of inserting
> references to keys which don't exist yet, and you can use joins from
> table_[12] to table_3 to do the same queries you would have done with the
> cross-referential tables.

One of the reasons to setup referential integrity constraints
is to avoid inserting references to keys that don't exist, so
getting around it with your 3-table setup looks a little odd
to me.

You'd better think about declaring your constraints INITIALLY
DEFERRED and cover the key- and reference-insertions by
proper transaction blocks.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2000-11-07 18:13:30 Re: libpq.so.2.0 problem
Previous Message Edward Q. Bridges 2000-11-07 17:16:50 linker (ld2/dllwrap) error for PL/Perl using Cygwin port