[Zope3-dev] Re: relational data

Michel Pelletier michel at dialnetwork.com
Wed May 4 13:46:58 EDT 2005


> Message: 7
> Date: Wed, 04 May 2005 08:17:09 +0200
> From: "Achim Domma (Procoders)" <domma at procoders.net>
> Subject: [Zope3-dev] relational data
> To: zope3-dev at zope.org
> Message-ID: <d59p0s$gr3$1 at sea.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hi,
> 
> I'm evaluating ZOPE for some projects we might have to implement. ZODB 
> looks very nice for storing object hierarchies but I don't understand 
> how to store relational data.
> 
> For example, f I store people and qualified realations between them, I 
> usally have a table 'person' which hold the person records, 
> 'relation_type' which hold the possible relations and 
> 'person_person_relation' which holds the ids of the related persons and 
> the id of the type of the relation.
> 
> I don't see how I would store something like this in ZODB and I want to 
> understand if it's better to stick with a relational database for such a 
> case. Or is there a solution, which I might not see at the moment?
> 
> This should be no criticism, I only want to understand what Zope is good 
> for and where something else might suite my needs better.

ZODB does not strictly require hierarchical object graphs, that's a
Zopeism, ZODB will allow you to construct arbitrary object graphs.
Given that it can store "relations" as well as it can store any other
object. Storing references like you describe can be done easily in ZODB.
There are three existing systems like this to my knowledge.  

Although the terminology differs depending on what system you are
looking at, I'll use RDF terms here, subject (referer), predicate
(reference) and object (referent).  So if your relationship is "Bob
likes Mary" then 'Bob' is the subject, 'likes' is the predicate, and
'Mary' is the object.  This subject/predicate/object model goes by many
names but for the sake of discussion lets call it SPO.

Storing these references can be done any number of ways, but in ZODB I
have seen two ways, the first is from Zemantic (http://zemantic.org/)
which is a very early Zope 3 product that stores RDF.  Zemantic lets you
store and query SPO relations (called "triples" in RDF).  Each subject,
predicate, and object is stored in a multi-dimensional ZODB BTree.

The second is Archetype references (for Zope 2) that use a ZCatalog to
store basically a very similar data structure to what Zemantic uses, a
three column "table" (constructed of ZCatalog indexes) that index the
relationships in each dimension.  Archetype references are pretty mature
and offer more features than Zemantic that go beyond RDF, but as of now
it's Zope 2 only.

The third framework comes with the SchoolBell Zope 3 product I have no
experience with and I don't know exactly how it stores its data, but I
suspect it is less "bleeding edge" than Zemantic (I can say that with
some confidence because I am in the middle of upgrading Zemantic to
rdflib 2.1, which is pretty radically different than 2.0).

Or, of course, you can just use a relational database which might give
you more piece of mind.

Hope that helps,

-Michel





More information about the Zope3-dev mailing list