Two tables refenceing each other's columns

From: GH <grasshacker(at)over-yonder(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Two tables refenceing each other's columns
Date: 2001-01-02 06:57:46
Message-ID: 20010102005746.C46834@over-yonder.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Is something like the following allowed (or is not a Bad Idea)?

table1
---------+-------------------------
id1 |serial primary key
col2 |int references table2(id2)

table2
---------+-------------------------
id2 |serial primary key
col2 |int references table1(id1)

Obviously, creating the tables is a problem since the constraints require
that the other table exists.
If doing the above is *not* a Bad Idea, how could I work around this
problem?
(That is, (how) can I add the constraints after table creation?
I imagine something with "create constraint trigger", but the manual is
not very clear on that.)

Thanks

dan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert B. Easter 2001-01-02 07:27:28 Re: Two tables refenceing each other's columns
Previous Message Matt Beauregard 2001-01-02 05:58:21 data change violation inside transaction