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

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: need elegant way to store and query tables with variable headers
Date: 2013-10-08 18:47:30
Message-ID: 1381258050947-5773750.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2013-10-08 18:50:38 Re: Urgent Help Required
Previous Message Gauthier, Dave 2013-10-08 18:27:24 need elegant way to store and query tables with variable headers