Re: Unique constraint over null values

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Unique constraint over null values
Дата
Msg-id 200209301050.05473.josh@agliodbs.com
обсуждение исходный текст
Ответ на Re: Unique constraint over null values  (Thrasher <thrasher@fibers.upc.es>)
Список pgsql-sql
Thrasher,

> I think I'll follow your advice, as this is the method that I had in my
> pocket to use if I had no response. I tried with TRIM and other
> functions in the CHECK constraint, but I guess that I cannot use
> functions over a check field.
>
> It surprised me, but anyway, I'll do that.
>
> Thanks a lot for your prompt reply

No problem.  You should also add a second constraint:
CHECK ((type = 'x' AND data2 <> 'blank value') OR (type = 'y' AND data2 =
'blank value'))

To enforce your other criterion.

Keeop in mind that depending on the rest of your data structure, there are
probably 8 different ways to approach this problem.  I'd reccomend, in fact,
a quick reading of Pascal's "Practical Issues in Database Management" on
normalization to see the different table structures that might work for you.

--
-Josh BerkusAglio Database SolutionsSan Francisco



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

Предыдущее
От: Thrasher
Дата:
Сообщение: Re: Unique constraint over null values
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] CURRENT_TIMESTAMP