From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | "Jon Horsman" <horshaq(at)gmail(dot)com> |
Subject: | Re: Foreign Unique Constraint |
Date: | 2007-03-27 15:58:42 |
Message-ID: | 200703271758.42413.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Jon Horsman wrote:
> Basically table 1 and table 2 both have the concept of an extension
> that must be unique but the rest of the info in the tables are
> different. I need to ensure that if i add an entry to table 1 with
> extension 1000 that it will fail if there is already an entry in
> table2 with the same extension.
Make a third table that contains all the extension and add two columns,
one referencing table 1 and one referencing table 2, and then add a
constraint that only one of the two can be not null.
It's not very pretty, but you can use views to make the access simpler.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-03-27 16:10:24 | Re: select vs. select count |
Previous Message | Richard Huxton | 2007-03-27 15:45:01 | Re: array_to_string |