> 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. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general