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

From Gauthier, Dave
Subject need elegant way to store and query tables with variable headers
Date
Msg-id 0AD01C53605506449BA127FB8B99E5E170D12962@FMSMSX114.amr.corp.intel.com
Whole thread Raw
Responses Re: need elegant way to store and query tables with variable headers  (David Johnston <polobo@yahoo.com>)
Re: need elegant way to store and query tables with variable headers  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general

Hi:

 

Longshot, but here goes....

 

Someone is asking me for a way to architect a model which will store basic table data (columns with names and rows), but the number and name of the columns are both variables.  I'll call these "data-tables" here.   

 

Example, Store this "data-table"....

 

'col1'     'col2'     'col3'     'val'

0             0             0             'a'

0             0             1             'b'

0             1             0             'c'

 

Then store this one...

 

'c1'         'c2'         'c3'         'c4'         'val'

0             0             0             0             'w'

0             0             0             1             'x'

0             0             1             0             'y'

0             0             1             1             'z

 

Order is important because they may want to reconstruct the table as is (e.g. 'w' comes before 'x' comes before 'y' ...)

 

Assume you can capture this info inside the context of a script (perl or something) which you would then need to store in a DB.  And assume you have a "data_id" in hand for each of these "data-tables" that could be used to link them to a parent table somewhere else in the DB. Finally, assume you'll never have to query outside the context of one of these data-tables.  IOW, you'll never have to come up with all "data_id" where "c3 = 1".  But you may need to update 'val' where data_id=100 and c1=0 and c2=1 and, ... etc.. .  And you may need to select on the data-table as if it was a real sql table.

 

Any ideas?

 

Thanks !

 

 

 

 

 

 

 

 

 

 

 

 

 

pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Looking for some advise on training materials
Next
From: David Johnston
Date:
Subject: Re: need elegant way to store and query tables with variable headers