Calling all DAL gurus. I have a table like this:
db.define_table('list_value',
Field('list_table','reference list_table'),
Field('list_field','reference list_field'),
Field('record_value'),
Field('row_id',required=True))
And sample data like this:
{list_table: 'places',list_field:'name',record_value:'starbucks',row_id=1}
{list_table: 'places',list_field:'zip_code',record_value:'11215',row_id=1}
{list_table: 'places',list_field:'name',record_value:'seattles
best',row_id=2}
{list_table: 'places',list_field:'zip_code',record_value:'65456',row_id=2}
{list_table: 'people',list_field:'name',record_value:'henry',row_id=1}
{list_table: 'people',list_field:'age',record_value:'33',row_id=1}
{list_table: 'people',list_field:'name',record_value:'chuck',row_id=2}
{list_table: 'people',list_field:'age',record_value:'64',row_id=2}
{list_table: 'people',list_field:'name',record_value:'randy',row_id=3}
{list_table: 'people',list_field:'age',record_value:'22',row_id=3}
Results filtered by list_table and grouped by row_id should assemble back
into rows of user-defined data. It is basically a set of user-defined
tables within a database table.
For instance, if the user queries for 'places' they should get this:
{name:'starbucks',zip_code:'11215'}
{name:'seattles best',zip_code:'65456'}
...or if they query for 'people' they get this:
{name:'henry',age:'33'}
{name:'chuck',age:'64'}
{name:'randy',age:'22'}
What is the most efficient query to do this? Any help is appreciated and
Happy New Year.
--