Re: need elegant way to store and query tables with variable headers - Mailing list pgsql-general

From David Johnston
Subject Re: need elegant way to store and query tables with variable headers
Date
Msg-id 1381258050947-5773750.post@n5.nabble.com
Whole thread Raw
In response to need elegant way to store and query tables with variable headers  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List 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 by date:

Previous
From: "Gauthier, Dave"
Date:
Subject: need elegant way to store and query tables with variable headers
Next
From: Adrian Klaver
Date:
Subject: Re: Urgent Help Required