>
> 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)
>
> db.NodeKeyword.word.requires=[IS_IN_DB(db,'Keyword.word','%(word)s',zero='select
>
> a value')]
>
Note, I don't think you need the '%(word)s' -- that will be used by default
because it is simply the field used as the constraint (i.e., the second
argument).
> I read about reference and list:reference in the book what exactly are
> they.
>
You could make db.NodeKeyword.word a reference field to the db.Keyword
table -- in that case, it will store the record id's (i.e., integers) of
the associated keywords in the Keyword table. That will require an
additional join between the NodeKeyword and Keyword table whenever you want
the actual word text itself.
With a list:reference field, you wouldn't have the NodeKeyword table at
all. Instead, you would add a "word" list:reference field to the Node table
referencing the Keyword table. It would store a list of Keyword table
record id's referencing a set of keywords. Simpler design and easier if you
just need to display keywords per node, but less efficient if you need to
search nodes by keyword (because you have to do a contains search on the
list:reference field).
Anthony