On Wednesday, July 6, 2016 at 8:39:57 AM UTC-4, Carlos Cesar Caballero wrote: > > Hi Anthony, that's exactly what I need, because (among other things) when > the parent key is part of the child primary key I can do something like > child.parent_id, and it works the same with a relationship of depth n, for > example in the relation author-book-page-sentence-word, I can ask what > author wrote a word just saying word.author_id without need to join word > with sentence with page with book to get the author id. >
Yes, but nothing stops you from doing that with the DAL: db.define_table('word', Field('sentence_id', 'reference sentence'), Field('page_id', 'reference page'), Field('book_id', 'reference book'), Field('author_id', 'reference author'), Field('word')) word = db.word(1) author_id = word.author_id In the above, db.word.author_id is not part of the primary key of the db.word table, but it is still a foreign key to the db.author table. But keep in mind that this is not that useful, as all you have is the record ID of the author -- if you want any details about the author, you still need to do a join or an additional query. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.