[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] Using || operator to fold multiple columns into one
From:       Rosser Schwarz <rosser.schwarz () gmail ! com>
Date:       2009-12-31 16:23:49
Message-ID: 37d451f70912310823y114ff7a7xd511ae4f5d369e2d () mail ! gmail ! com
[Download RAW message or body]

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

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic