From: | Decibel! <decibel(at)decibel(dot)org> |
---|---|
To: | Kenneth Porter <shiva(at)sewingwitch(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org, "G(dot) J(dot) Walsh" <gjwalsh(at)dscdirectionalservices(dot)com> |
Subject: | Re: populating arrays with default values |
Date: | 2007-11-19 04:31:43 |
Message-ID: | 1745C83A-C5CE-4397-9CC1-3BEAAD3024BB@decibel.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Nov 14, 2007, at 8:30 PM, Kenneth Porter wrote:
> On Wednesday, November 14, 2007 12:09 PM -0800 "G. J. Walsh"
> <gjwalsh(at)dscdirectionalservices(dot)com> wrote:
>
>> I come from a long background with C and isam. Moving into php and
>> postgresql is therefore not all that strange, but I suffer with the
>> comparative lack of structure at times.
>
> Same here. I'm a power C++ guy but relatively new at SQL. I can
> read it but not yet write it fluently.
My advice: remember that SQL is a set definition language. Always
think in terms of sets/groups of data, and not in terms of a series
of operations you need to perform.
>> I deal with a lot of psych scoring and am establishing tables
>> which will
>> contain the response patterns for each individual test within a
>> battery.
>> In defining this, I plan on something like: ans CHAR(1) ARRAY[192]
>>
>> But I learned that PostgreSQL does not 'enforce' this. I would rather
>> have an '?' placed in each of the 192 array elements (and thereby
>> constrain with NOT NULL) to indicate lack of a response (the default)
>> when the test records are first established for the client.
>
> Instead of a char, could you use an enumeration? Are there in fact
> 256 distinct answers for each array position? (I'm not certain that
> SQL, or the PostgreSQL dialect, have such a thing.)
IIRC, in 8.3 elements within an array can be NULL, would would be
what you're looking for. ('?' is just a not-so-good way of
representing "I don't know", which is why NULL is for. :) )
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-19 04:39:54 | Re: optimizing a (simple?) query on a largeish table |
Previous Message | Dr. Kurt Ruff | 2007-11-19 04:15:27 | optimizing a (simple?) query on a largeish table |