Why not simply write an onvalidation function? When you save a record with form accepts this would check to ensure that you only have one first_chapter for that story_id.
On Apr 6, 9:29 pm, guruyaya <[email protected]> wrote: > Here's a simplified version of a model I'm working on: > > db.define_table('story', > Field('title'), > Field('description', 'text'), > Field('first_chapter', db.chapter) > ) > > db.define_table('chapter', > Field('title'), > Field('tale', 'text'), > Field('story_id',db.story) > ) > > As you can imagine, I have a problem here. I cannot reference the > first chapter in the story table, because chapter is not yet defined, > but I cannot write the tables backwards, because story won't be > defined. > I was wondering if there's any way of doing this elegantly, or I'll > just have to count on the first chapter written of any story - to be > the first chapter. > Thanks in advance > Yaya

