From: Rosser Schwarz <rosser.schwarz@gmail.com>
To: Bryce Nesbitt <bryce2@obviously.com>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Cc: Craig Ringer <craig@postnewspapers.com.au>
Subject: Re: Using || operator to fold multiple columns into one
Date: Thu, 31 Dec 2009 09:23:49 -0700
Message-ID: <37d451f70912310823y114ff7a7xd511ae4f5d369e2d@mail.gmail.com> (raw)
In-Reply-To: <4B3A9448.20308@obviously.com>
References: <4B31D619.1090706@obviously.com>
<4B31D86D.9030000@postnewspapers.com.au>
<37d451f70912231304i3515e575x69b31638962739a6@mail.gmail.com>
<4B32DB14.6080308@postnewspapers.com.au>
<4B3A9448.20308@obviously.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rosser.schwarz@gmail.com, bryce2@obviously.com, craig@postnewspapers.com.au
Subject: Re: Using || operator to fold multiple columns into one
In-Reply-To: <37d451f70912310823y114ff7a7xd511ae4f5d369e2d@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox