Subject | hierarchical tree structure |
---|---|
Author | jwcanada |
Post date | 2001-12-26T22:54:40Z |
What is the best way to store and retrieve hierarchical information?
I am think about to create a table like
ID, PARARENT_ID, SUBJECT
1, NULL, '1 root subject'
2, NULL. '2 root subject'
3, 2, '2.3...under 2'
4, 1, '1,4 ..under 3'
5, 3, '2.3.5 .. under 2.3'
6, 1, '1.6 under 1'
7, 6, '6.7 under 6'
However, i could not figure out how to query to display in a tree
order.
1, NULL, '1 root subject'
4, 1, '1,4 ..under 3'
6, 1, '1.6 under 1'
7, 6, '6.7 under 6'
2, NULL. '2 root subject'
3, 2, '2.3...under 2'
5, 3, '2.3.5 .. under 2.3'
I would appreciate very much for expert advice!!
Thanks
jw
I am think about to create a table like
ID, PARARENT_ID, SUBJECT
1, NULL, '1 root subject'
2, NULL. '2 root subject'
3, 2, '2.3...under 2'
4, 1, '1,4 ..under 3'
5, 3, '2.3.5 .. under 2.3'
6, 1, '1.6 under 1'
7, 6, '6.7 under 6'
However, i could not figure out how to query to display in a tree
order.
1, NULL, '1 root subject'
4, 1, '1,4 ..under 3'
6, 1, '1.6 under 1'
7, 6, '6.7 under 6'
2, NULL. '2 root subject'
3, 2, '2.3...under 2'
5, 3, '2.3.5 .. under 2.3'
I would appreciate very much for expert advice!!
Thanks
jw