Re: populating arrays with default values

Поиск
Список
Период
Сортировка
От Decibel!
Тема Re: populating arrays with default values
Дата
Msg-id 1745C83A-C5CE-4397-9CC1-3BEAAD3024BB@decibel.org
обсуждение исходный текст
Ответ на Re: populating arrays with default values  (Kenneth Porter <shiva@sewingwitch.com>)
Список 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@dscdirectionalservices.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@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828



Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: optimizing a (simple?) query on a largeish table
Следующее
От: "Sean Davis"
Дата:
Сообщение: xpath question