I defined the following tables:
db.define_table('Node',
Field('createdOn',type='datetime',writable=False,readable=False),
Field('modifiedOn',type='datetime',writable= False,readable=False),
migrate=False)
db.define_table('Keyword',
Field('word',length=128,default='',notnull=True,unique=True),
migrate=False)
db.define_table('NodeKeyword',
Field('nodeID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
Field('word',length=128,default='',notnull=True,ondelete='CASCADE'),
migrate=False)
The table Keyword contains keywords like counselor, mediator, coach ...
The table NodeKeyword should contain ids and keywords:
1 counselor
2 counselor
3 mediator
Is there a way to implement this in web2py? I now have a validator:
db.NodeKeyword.word.requires=[IS_IN_DB(db,'Keyword.word','%(word)s',zero='select
a value')]
and added the foreign key constraint to the postgres datbase manually.
I read about reference and list:reference in the book what exactly are they.
Kind regards,
Annet.