Re: REFERENCES constraint - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: REFERENCES constraint
Date
Msg-id Pine.BSF.4.21.0108081111280.40255-100000@megazone23.bigpanda.com
Whole thread Raw
In response to REFERENCES constraint  (Cedar Cox <cedarc@visionforisrael.com>)
List 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.




pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: REFERENCES constraint
Next
From: "Josh Berkus"
Date:
Subject: Re: Problem with aggregate functions and GROUP BY