Re: Other tree representations in SQL [inorder]
Date: Wed, 4 Dec 2002 16:35:38 -0800
Message-ID: <asl7ah$59i$1_at_news.etf.bg.ac.yu>
: Vadim Tropashko suggested that we could represent a tree structure in
: SQL by storing a traversal sequence number and the level of each node
: to represent a hierarchy. This would be an alternative to my nested
: sets model
Although (traversal-sequence-number, level) representation "works" when using preorder and postorder traversal (there exists at most one tree that matches given set of (tsn, l) values), when using inorder traversal situation is somewhat different. Consider the following two trees (nodes 1 and 4 are left children of node 6, node 9 is right child of node 6, and so on. Nodes having a "/" above are left children and node having a "\" are right children):
6
/ / \
1 4 9
/ / \ / /
2 3 5 7 8
6
/ / \
1 4 9
\ / \ / /
2 3 5 7 8
If we try to represent those trees using the suggested model, we'll find out that they share the same representation. So, this approach works only with binary trees...
regards,
Damjan S. Vujnovic
University of Belgrade
School of Electrical Engineering
Department of Computer Engineering & Informatics
Belgrade, Yugoslavia
http://galeb.etf.bg.ac.yu/~damjan/ Received on Thu Dec 05 2002 - 01:35:38 CET
