Re: need elegant way to store and query tables with variable headers

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: need elegant way to store and query tables with variable headers
Дата
Msg-id 1381258050947-5773750.post@n5.nabble.com
обсуждение исходный текст
Ответ на need elegant way to store and query tables with variable headers  ("Gauthier, Dave" <dave.gauthier@intel.com>)
Список pgsql-general
> Example, Store this "data-table"....
>
> 'col1'     'col2'     'col3'     'val'
> 0             0             0             'a'
> 0             0             1             'b'
> 0             1             0             'c'

Random thoughts:

If you know of a non-elegant way to accomplish this I'd recommend just using
that.

The solution to the problem will likely present itself once you are able to
accurately, and in sufficient detail, explain what it is you are trying to
accomplish.

"c(ol)1 ... c(ol)3, etc" seem like good candidates for an array typed
column.  "val" is a column and you'd need some kind of "index/order" column
since relations do not have natural ordering.  And then the "data_id"
foreign key column.  The PK table for data_id can store what each array
position in the "data_columns" array on the FK table is named/called.

SELECT index, value FROM table_rows WHERE data_id = '...' AND cols[3] = 1
AND cols[4] = 1;

David J.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/need-elegant-way-to-store-and-query-tables-with-variable-headers-tp5773749p5773750.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


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

Предыдущее
От: "Gauthier, Dave"
Дата:
Сообщение: need elegant way to store and query tables with variable headers
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Urgent Help Required