From: | Rosser Schwarz <rosser(dot)schwarz(at)gmail(dot)com> |
---|---|
To: | Bryce Nesbitt <bryce2(at)obviously(dot)com> |
Cc: | sql pgsql <pgsql-sql(at)postgresql(dot)org>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
Subject: | Re: Using || operator to fold multiple columns into one |
Date: | 2009-12-31 16:23:49 |
Message-ID: | 37d451f70912310823y114ff7a7xd511ae4f5d369e2d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, Dec 29, 2009 at 4:44 PM, Bryce Nesbitt <bryce2(at)obviously(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Gould | 2009-12-31 17:36:29 | Proper case function |
Previous Message | Brian Sherwood | 2009-12-31 16:23:26 | loading a file into a field |