[ZODB-Dev] Associations for ZODB

Roché Compaan roche at upfrontsystems.co.za
Mon Jun 23 21:33:42 EDT 2003


* Shane Hathaway <shane at zope.com> [2003-06-23 17:34]:
> Roché Compaan wrote:
> >There was a thread about associations/relationships about 2 months ago
> >on this list. We prototyped several approaches and some turned out to
> >work really well. What is super about having associations in a ZODB app
> >is that you don't use RDBMS semantics to do something object oriented.
> >In our older apps we used to have lots of OtherClassID attributes on
> >classes representing the relationship between objects eg. a
> >ContactPerson would have a CustomerID. Now ContactPerson has a Customer
> >reference which is accessible and directly manipulated as an attribute,
> >ContactPerson.Customer. Since references are bidirectional Customers can
> >access their contacts through its Customer.ContactPersons reference.
> >References are ComputedAttributes.
> 
> I'm glad to hear you've continued work on this.  Through our 
> discussions, I've come to feel that associations would be extremely 
> beneficial for ZODB applications, and that associations have important 
> differences from the relationships envisioned in Zope 3.  In particular, 
> translating a UML static class model to code should be easier with 
> associations than using Zope 3 relationships directly.

I'm also glad I continued with it ;-). The rewards so far has been
tremendous. Thus far my goal was to make it work for Zope 2 and ZODB 3
because we need it for our existing Zope 2 apps but it should be even
easier to make it work for Zope 3 and ZODB 4.

So far references and associations are very stable and early benchmarks
show good performance. As I mentioned I am now busy with a query
service. For me the ideal ZODB query service would unify the
functionality of the Catalog and Associations and make complex joins
possible and I am almost there.

> >The next step was application specific but can also turn out to be
> >generally useful. We needed to join results for different meta_types
> >returned by the unified query service. I was working on this over the
> >weekend and that's why I was curious about n-way join algorithms. So far
> >it looks very promising and I am very excited to have the ability to do
> >complex joins on objects in the ZODB. Having infrastructure like
> >associations seems to makes this very possible and very fast. We hope to
> >release our ZAssociations product soon :-)
> 
> FYI: there is also a multiunion() utility in recent versions of the 
> BTrees code.  It accepts a sequence of sets and returns a set.  Use it 
> where you can, because it was created and optimized by Tim "I can make 
> it faster yet" Peters. :-)

I rely heavily on the BTrees package for the query service. What amazes
me is that I can kick around some integers and a couple of milliseconds
later I have a result :-)

-- 
Roché Compaan
Upfront Systems                 http://www.upfrontsystems.co.za



More information about the ZODB-Dev mailing list