On May 5, 2008, at 5:11 PM, Matt Haggard wrote:
> > I've got a kind of goofy schema, and I'm trying to map it. I've got > Questionnaire types, Sections and Questions all joined in a single > association table: > > join_table : type_id | section_id | question_id > questions_table : id | question_text > sections_table : id | section_name > types_table : id | type_name > > So, a single question can appear in different sections for different > types. How do I do the mapping? This is what I've got, and it > doesn't work. > > mapper(Question, questions_table) > mapper(Section, sections_table, properties={ > 'questions':relation(Question, backref='section', > secondary=join_table) > }) > mapper(QType, types_table, properties={ > 'sections':relation(Section, > backref = 'type', > secondary = join_table > primaryjoin = types_table.c.id==join_table.c.type_id, > secondaryjoin = join_table.c.section_id==sections_table.id > ) > }) your table is not a many-to-many table, its just another entity table with associations to other entities. "secondary" is not the appropriate construct in this case; use an association mapping : http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_patterns_association --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---