[ZODB-Dev] n-way join algoritms

Shane Hathaway shane at zope.com
Mon Jun 23 12:32:33 EDT 2003


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 had some issues with the early implementation, but you were definitely 
on the right track.  Don't let me slow you down. :-)

> 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. :-)

Shane




More information about the ZODB-Dev mailing list