Hi Oleg! You are right, there is no problem because you defined the intermediate tables.
The issue comes from this: > a.addB1(b1) > a.addB2(b2) what if it makes more sense to have a1 = A () a2 = A () a3 = A () b1 = B () a1.add (b1) b1.add (a2) b1.add (a3) Notice that the relationship is not symmetric. Am I making any sense? Or should I try to get some sleep? :) Regards, Miguel Tavares 2009/8/12 Oleg Broytmann <p...@phd.pp.ru>: > On Wed, Aug 12, 2009 at 11:58:38AM +0100, Miguel Tavares wrote: >> Running your example this is the schema on the database: >> CREATE TABLE a ( >> id INTEGER PRIMARY KEY >> ); >> CREATE TABLE a1_b1 ( >> a_id INT NOT NULL, >> b_id INT NOT NULL >> ); >> CREATE TABLE a2_b2 ( >> a_id INT NOT NULL, >> b_id INT NOT NULL >> ); >> CREATE TABLE b ( >> id INTEGER PRIMARY KEY >> ); > > I don't see any problem with the schema. > > class A (SQLObject): > B1 = RelatedJoin ('B', addRemoveName='B1', intermediateTable='a1_b1') > B2 = RelatedJoin ('B', addRemoveName='B2', intermediateTable='a2_b2') > > class B (SQLObject): > A1 = RelatedJoin ('A', addRemoveName='A1', intermediateTable='a1_b1') > A2 = RelatedJoin ('A', addRemoveName='A2', intermediateTable='a2_b1') > > A.createTable() > B.createTable() > > a = A() > b1 = B() > b2 = B() > a.addB1(b1) > a.addB2(b2) > print a.B1 > print a.B2 > > 1/QueryR : CREATE TABLE a ( > id INTEGER PRIMARY KEY > ) > 2/QueryR : CREATE TABLE a1_b1 ( > a_id INT NOT NULL, > b_id INT NOT NULL > ) > 3/QueryR : CREATE TABLE a2_b2 ( > a_id INT NOT NULL, > b_id INT NOT NULL > ) > 4/QueryR : CREATE TABLE b ( > id INTEGER PRIMARY KEY > ) > 5/QueryR : INSERT INTO a VALUES (NULL) > 6/QueryR : SELECT NULL FROM a WHERE ((a.id) = (1)) > 7/QueryR : INSERT INTO b VALUES (NULL) > 8/QueryR : SELECT NULL FROM b WHERE ((b.id) = (1)) > 9/QueryR : INSERT INTO b VALUES (NULL) > 10/QueryR : SELECT NULL FROM b WHERE ((b.id) = (2)) > 11/QueryR : INSERT INTO a1_b1 (a_id, b_id) VALUES (1, 1) > 12/QueryR : INSERT INTO a2_b2 (a_id, b_id) VALUES (1, 2) > 13/QueryR : SELECT b_id FROM a1_b1 WHERE a_id = (1) > [<B 1 >] > 14/QueryR : SELECT b_id FROM a2_b2 WHERE a_id = (1) > [<B 2 >] > > Ok? > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ...@phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > sqlobject-discuss mailing list > sqlobject-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss