Re: how to implement a foreign key type constraint against a not unique column

Поиск
Список
Период
Сортировка
От Richard Broersma
Тема Re: how to implement a foreign key type constraint against a not unique column
Дата
Msg-id 396486430901211315k791876f7hd3155ab3d009dff8@mail.gmail.com
обсуждение исходный текст
Ответ на how to implement a foreign key type constraint against a not unique column  ("Brent Wood" <b.wood@niwa.co.nz>)
Список pgsql-general
On Wed, Jan 21, 2009 at 12:53 PM, Brent Wood <b.wood@niwa.co.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,
thena 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Brent Wood"
Дата:
Сообщение: how to implement a foreign key type constraint against a not unique column
Следующее
От: Igor Katson
Дата:
Сообщение: A complex plproxy query