On 2/7/2010 4:56 PM, Ed Leafe wrote: > On Feb 7, 2010, at 9:38 AM, sim wrote: > > >> Lets say I have a 3 tables: Products, Users and UserProducts. >> UserProducts has 2 FKs , ProductID and UserID, showing which products >> are used by which user. >> I create 3 bizobjs, one for each table. >> Should UserProducts be a child of Users or Products? >> > Think about it this way: which table do you want to browse > independently? That will determine which table's values are dependent on the > independent table's current record. > > I'm assuming here that UserProduct is a M:M intermediate table, > commonly called an allocation or cross-reference table. > > Let's say you want to browse the Products table and see all the Users > records that are related to the current Product, then UserProduct would be a > child of Product, because its values are dependent on the current Product > record. The User table would then be dependent on the current record in > UserProducts, so it would be a child of UserProducts. > > But if you are browsing by user, and want to see the products that they > have, you would reverse things: Users would be the independent table; > UserProducts would be a child of that, and Products would be a child of > UserProducts. > > This is standard relational table theory, not anything specific to > Dabo. The bizobj relations in Dabo are designed to reflect typical relational > designs. > > Does this make things any clearer? > > > -- Ed Leafe I understand it quite clearly. The confusing part for me was simply that when I browse the Users I want to see what products they are using and when I browse the Products I want to see what users are using them. I see from Jacek's code, that instead of defining the LinkField in the class definition, I should define it after creating the instance and that way I can have 2 different instances of UserProducts. One as a child of Products and one as a child of Users.
Thank you both for your explanations, it certainly helped to clarify. Sim _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
