On 16 January 2012 22:35, Christian Winterhager <
[email protected]> wrote:

> One of the standard examples  of many-to-many Relations is a library. For
> simplicity i choose only 3 Tables:
>
> db.define_table ('author',
>     Field ('name', 'string', length=100))
>
> db.define_table ('verb',
>    Field ('bnr', db.book ),
>    Field ('anr', db.author ),
>     )
>
> db.define_table ('book',
>     Field('title', 'string', length=250))
>
> It is very easy to insert a new book, one or more author and the
> corresponding record
> in the table "verb". But i found no way to insert a book with the
> CRUD-Method. The 
> complexity<http://dict.leo.org/ende?lp=ende&p=DOKJAA&search=complexity&trestr=0x8001>
> is that i first must insert a row into  table "book", then one into table
> "author" and last i have to connect
> the inserted rows with the corresponding numbers 'bnr' and 'anr' in table
> "verb". Does anyone know if there
> is a way to do that with CRUD?
>

I don't think you can do this in one step.

I would do the following:

1. Find the author in the author table and if it is not there, insert.  For
each author, collect the id of the record.
2. Then insert the book and get the id
3. Then for each author create a record in 'verb'. I would do this in the
background without any form involved.

Regards
Johann



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Reply via email to