Hi,

I'm just learning about Object databases, and I stumbled across Zope.

I'm trying to store data that inherently has a hierarchical (tree) structure. As I have it currently implemented, each object points to another object of the same type by storing the ID of its parent.

So currently in SQL, to find all the children of object id=4, I'd query:

SELECT * from TreeNodes WHERE parent=4;

To find the parent of a given object, obviously, I'd just query (say 3 is parent of 4):

SELECT * from TreeNodes WHERE id=3;

The tree structure is a very important part of the data and cannot be compromised.

In the Wikipedia article describing object databases, it mentioned that data access can be faster because related data could be found by following pointers. This makes sense. In the object domain, if I maintain a set of references for the parent and child in each TreeNode, traversal around the tree would be very quick.

I don't understand how I can use ZODB to do this, however. From what I can gather from reading the manual, if I simply stored variables referring to the parent and children in every TreeNode, I'd end up storing the whole tree of TreeNodes's every time I wanted to store that one TreeNode. (Presumably, because ZODB would follow all the references recursively.)

I suppose I could use the old method of storing only the identifiers of the parents/children. Is there a way ZODB can help me with efficient traversal of persistent objects in a tree structure?

Tommy Li

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to