On Thursday, October 28, 2010 01:06:30 am chaouche yacine wrote: > Hello, > > I discovered dabo yesterday, I haven't coded anything yet, just following > the pycon2010 tutorial. I have a documentation request about BizObj > relations. I didn't understand them. If the tutorial could give an > immediate code example on how to set a relation b/w two bizobjs that would > be great. In comparison, I found elixir's documentation about that subject > very clear and straightforward and understood it from my first reading > http://elixir.ematia.de/trac/wiki/TutorialDivingIn#a4.Simplerelationships. > > I look forward into using Dabo for my next project, I hope to hear from you > soon. > > Cheers, > > Y.Chaouche
I think you are right - I don't see anything on the wiki that explains how bizobj's can be related. It's a relatively simple thing to understand. I'm guessing it's the 'how' that is the issue. A little background: Tables in a database are often related to each other with keys. A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table. Take the case where we have a customer with multiple orders. The customer has a unique primary key and in each of the orders there is a field containing the customer key (a foreign key). We can then relate the foreign key in the orders to the customer with same primary key. BTW this is exactly how SQL joins work. This is often called a parent child relationship. What Dabo does: Dabo makes it easy to use the key relationship. Dabo provides several attrb's to help define the relationships. Each bizobj is defined in your code. It does not matter if you hand code the definition or are using either the ClassDesigner or the AppWizard. The table you want to use is defined. You can then tell framework what special relationships are required. So in my definition of my orders table (a child of customers) I have some like below: bizobj.ParentLinkField = "pkid" # the unique customer key bizobj.LinkField = "fk_clientid" # the foreign key in orders bizobj.FillLinkFromParent = True # a way to track new records After you define the relationship Dabo takes care of keeping the relationship valid. If you move to a new customer record the orders table will follow. If you require info on how Dabo does this - you'll need to read the source. As always feel free to correct me. This is just how I think about the subject. Johnf _______________________________________________ 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]
