From: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
---|---|
To: | Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to implement a foreign key type constraint against a not unique column |
Date: | 2009-01-21 21:15:18 |
Message-ID: | 396486430901211315k791876f7hd3155ab3d009dff8@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jan 21, 2009 at 12:53 PM, Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> wrote:
> I believe it is possible by using a table with nulls for the -1 values with a unique index on it as the foreign key, then a view which uses case or coalesce to present the nulls as -1, but this seems a cumbersome workaround.
This will work and yes it is a bit cumbersome but I don't think that
there is much else that can be done.
Another solution that is probably more cumbersome and ugly would be to
vertically partition your table and include all non -1 values in it.
Then use this table as the reference for your foreign key. Then
create your own trigger to keep these two table in sync with each
other.
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
From | Date | Subject | |
---|---|---|---|
Next Message | Keaton Adams | 2009-01-21 22:44:45 | Check if column is substring of another column |
Previous Message | Brent Wood | 2009-01-21 20:53:54 | how to implement a foreign key type constraint against a not unique column |