Re: REFERENCES constraint

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Cedar Cox <cedarc(at)visionforisrael(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: REFERENCES constraint
Date: 2001-08-08 18:14:08
Message-ID: Pine.BSF.4.21.0108081111280.40255-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 8 Aug 2001, Cedar Cox wrote:

>
> Two questions (maybe they are silly..)
>
> 1. Can a column reference more than one table? (This assumes you use a
> single sequence to generate the IDs for both "tbla" and "tblb". I guess
> you would also have the problem of enforcing a unique index. Say what?!
> A unique index across multiple tables.. absurd :) eg..
>
> CREATE TABLE blah (
> id int4,
> f_id int4 REFERENCES tbla (id) REFERENCES tblb (id)
> )

Yes, you should be able to do this, but it won't do what you want, it'll
make it be required in both tables. You'll need to do this one by hand.

> 2. Can a column reference another column in the same table? eg..
>
> CREATE TABLE bloo (
> id int4,
> p_id int4 REFERENCES bloo (id)
> -- or
> --p_id int4 REFERENCES (id)
> )

Yes, using your first syntax that should work.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-08-08 20:04:39 Re: Problem with aggregate functions and GROUP BY
Previous Message Jan Wieck 2001-08-08 17:50:52 Re: REFERENCES constraint