dynamic naming for hierarchical problem
gzeljko
gzeljko at sezampro.yu
Fri Aug 10 23:14:24 EDT 2001
From: Jeremy and Debra Jones <dnjjones at yahoo.com>
>
> 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.
>
No, one table:
TBL
( PARENT, CHILD, CHILD_ATRIBUTE1,..,
PRIMARY KEY (PARENT, CHILD))
example:
SELECT CHILD FROM TBL WHERE PARENT = 'ROOT';
and continue as user asks (or automaticaly).
gzeljko
More information about the Python-list
mailing list