On Jul 18, 2011, at 9:29 AM, Ismael Serratos wrote:
> Hi!! How could I make custom fields for each record in a model, I mean:

Seems like the answer depends on knowing more than we do about the apps 
requirements.

If you don't need direct SQL (eg search) access to the custom fields, you could 
serialize an info dictionary into a blob in the room table.

If you do need direct access, and all the info fields have the same type 
(string, for example), then how about a roominfo table, with a key and a value 
field, along with a room ID? Another buildinginfo table could contain the info 
keys legal for each building.

> 
> I have:
> 
> db.define_table('building',
>     Field('name','string'),
>     Field('comment', 'string'))
> 
> db.define_table('room',
>     Field('name','string'),
>     Field('owner','string'),
>     Field('building',db.building))
> 
> 
> But every building need some extra info about each room, for example
> 
> Building1 needed info:
> 
> room.name room.owner room.building room.xinfo room.yinfo
> 
> 
> Building 2 needed info:
> 
> room.name room.owner room.building room.ainfo room.binfo
> 
> etc, etc.
> 
> 
> Basically following this structure:  
> 
> 
> project                                   room                custom_attribs
> -----                                     -------------             
> --------------
> attrib_assoc_id    -->         id                  <--  assoc_id
> ...                                      
> 
> 
>                                                    
> 


Reply via email to