dynamic naming for hierarchical problem

Jeremy and Debra Jones dnjjones at yahoo.com
Fri Aug 10 22:41:05 EDT 2001


----- Original Message -----
From: gzeljko <gzeljko at sezampro.yu>
To: <python-list at python.org>
Sent: Friday, August 10, 2001 9:25 PM
Subject: Re: dynamic naming for hierarchical problem


>
> Good comparison, but very often 'single linked list' here is
> adequate as backup structure for visual-tree-control.
> It can be simple stored:
> in one rdbms (indexed) table { parent, child, child_atributes }
> or Python (or bsddb) dictionary { parent: [child1, chid2 ..]}.
>
> gzeljko
>

It seems like if you were to do it in a rdbms, you would need at least two
tables:

1)  one table with the definition of the thing itself: a primary
identification key, name, parent, any extra info that you may want to put in
there about the thing.
2)  another table that has a foreign identification key linking back to the
primary key in the first table, and another foreign key linking back to the
primary key of the first table of the children of this particular thing.

Since any particular thing can have multiple children and only one parent,
and you would want to look up and down the hierarchy, it seems like you
would have to set it up like the above.

The dictionary approach winds up getting a whole lot more convoluted a lot
more quickly than what I would desire.  As Alex Martelli pointed out,
keeping it simple is probably the best bet.  And as Peter Hansen pointed
out, there is a very simple solution in reading in an XML file and creating
a DOM object out of it and walking down the hierarchy tree.  (BTW - I am
working on this right now.  It looks like this will, indeed, be an ideal
solution for my problem.  Thanks, Peter.)  In my situation, since I am
responsible for creating the files that I am reading in anyway, I can very
easily re-format them so that they are a simple XML file and represent them
in a tree view with Tix.Tree and xml.dom.

Anyway, once I get a sample working, I will post it to the group.  I noticed
that there is an XML tools module just announced today (for python) that may
help my in my quest.  I may be reinventing the wheel by going the tix.tree
and xml.dom route if they have already done that work for me...


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the Python-list mailing list