I think this is more of a data modeling question than web2py. I would have one table called "content" with an extra column "content_type" . You could define queries over the top if you just want one ofthe three.
Your M:M table logically joins to "content". You sort of have three subtype tables, but they are identical in structure so there is no reason to separate, On Jan 6, 5:22 am, lyn2py <lyn...@gmail.com> wrote: > I have tables with individual properties, > > db.define_table('article', > Field('title', 'string', length=255,required=True), > Field('description', 'text',required=True), > ) > db.define_table('post', > Field('title', 'string', length=255,required=True), > Field('description', 'text',required=True), > ) > db.define_table('page', > Field('title', 'string', length=255,required=True), > Field('description', 'text',required=True), > ) > > And I have a table with many-to-many relationship (with different > tables): > > db.define_table('action', > Field('user_id','reference > auth_user',default=auth.user_id,required=True), > > Field('action','string',requires=IS_IN_SET(('fav','subscribe','report','fol > low')),required=True), > Field('table',requires=???,required=True), > Field('table_id','integer',default=???,required=True), > ) > > My questions: > 1.. The field, "table" is actually one of the tables, article/post/ > page. Is the only correct way to use > requires=IS_IN_SET(('article','post','page')) ? > > 2.. "table_id" is actually dependent on the "table" selected. what > should I put for "default=???" > > 3.. Can I set a different set of IS_IN_SET for "action" field, > depending on the "table" field chosen? > > 4.. Finally, if the above is the wrong approach, how should I do it > correctly (best practice?) > > Thanks!