Re: Is cycle references? - Mailing list pgsql-general

From Tod McQuillin
Subject Re: Is cycle references?
Date
Msg-id Pine.GSO.4.21.0011011931270.6485-100000@sysadmin
Whole thread Raw
In response to Is cycle references?  (<limin@www.pumpkinnet.com>)
Responses Re: Is cycle references?
List pgsql-general
On Wed, 1 Nov 2000 limin@www.pumpkinnet.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.
--
Tod McQuillin




pgsql-general by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: pgsql-general Digest
Next
From: Ashley Clark
Date:
Subject: Re: psql defaults file?