[ZODB-Dev] How do you handle changes to BTree key values?

Patrick K. O'Brien pobrien@orbtech.com
Tue, 9 Oct 2001 08:54:06 -0500


I think I understand what you are saying here. The problem I have is
reconciling your advise with the fact that other people seem to be using a
meaningless generated value as their BTree key. I don't see how that would
be useful as an index, unless that value then became a "foreign key"
somewhere else. But then it sounds like we're turning the ZODB into a
relational database. (At least in a relational database the engine takes
care of maintaining the indexes when the indexed field's values change.)

So I'm still struggling with this, but do appreciate your help. I'll take a
look at the Catalog stuff to see if that helps. Also, do you think ZPatterns
or TransWarp would help me get a handle on things? Keep in mind, I'm not
interested in Zope as much as I am in using ZODB with regular
Python/wxPython apps.

Thanks again.

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: zodb-dev-admin@zope.org [mailto:zodb-dev-admin@zope.org]On Behalf Of
Steve Alexander
Sent: Tuesday, October 09, 2001 3:12 AM
To: pobrien@orbtech.com
Cc: ZODB
Subject: Re: [ZODB-Dev] How do you handle changes to BTree key values?

Patrick K. O'Brien wrote:

>
> So if all I wanted was a collection of users, why would I want to use any
of
> the BTrees, which required a key? What does the key buy you in ZODB?
Should
> the key be a value that never changes? Does the key become an attribute in
> other objects similar to a foreign key in a relational database? Wouldn't
> you just use an object reference itself? Why am I finding this so
difficult
> to get my brain around? (Too many years with relational?)


If I'm storing Person objects in a BTree, and using aPerson.name as the
key, then it is because I anticipate that later I will be given a name,
and I will want to retrieve the Person object that has that name, quickly.

If more than one person has the same name, I'd store a dict of Person
objects at that key in the BTree.

If a person's name changed, I'd remove that Person from the BTree,
change their name attribute, and then add them again with the new name.

Here, the BTree is acting like a simple index in a relational database.

For more complex situations, I would store the Person objects by the key
they would be most often retrived by, and also keep other indexes if I
needed random access via other attributes of a Person. This is what the
Catalog product (wrapped in ZCatalog in Zope) is for.

--
Steve Alexander
Software Engineer
Cat-Box limited






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

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