Re: Using || operator to fold multiple columns into one

Поиск
Список
Период
Сортировка
От Rosser Schwarz
Тема Re: Using || operator to fold multiple columns into one
Дата
Msg-id 37d451f70912310823y114ff7a7xd511ae4f5d369e2d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Using || operator to fold multiple columns into one  (Bryce Nesbitt <bryce2@obviously.com>)
Список pgsql-sql
On Tue, Dec 29, 2009 at 4:44 PM, Bryce Nesbitt <bryce2@obviously.com> wrote:

> Craig is correct in the OP attempt.   All but one field is intended to be null

Ah; my misunderstanding, then.  Sorry for the noise.

> Duplicate rows, or data in multiple columns, would wreck havoc on the
> scheme.  If there is a better way, I am all eyes.

One thought would be to add a couple of constraints: a CHECK
constraint to ensure that one and only one of the columns is populated
(think "t_number IS NOT NULL AND t_string IS NULL AND t_boolean IS
NULL AND t_date IS NULL OR..."), and a UNIQUE constraint against
(context_key, t_number, t_string, t_boolean, t_date).  That's not
really a "better" way, but it should prevent both duplicate and
"compound" data.

rls

--
:wq


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

Предыдущее
От: Brian Sherwood
Дата:
Сообщение: loading a file into a field
Следующее
От: Michael Gould
Дата:
Сообщение: Proper case function