in reply to message board thread quandary
you could maintain a table like:blog 1 - reply 2 - reply 4 - reply 5 - reply 6 - reply 3 - reply 7
This would allow you to say: give me all the descendants of blog 1, or of reply 2. It has its own complications in that you're maintaining a separate table, and so need to keep the two in sync.ancestor_id descendant_id ---------------------------- 1 2 1 3 1 4 1 5 1 6 1 7 2 4 2 5 2 6 3 7 5 6
There are numerous patterns for expressing hierarchies, and the most effective one depends on the depth of your trees and how often that data changes. Have a look at Trees in SQL, adjacency lists and sorting. for a discussion of some of these. Also, look for anything by Joe Celko, author of Joe Celko's Trees and Hierarchies in SQL for Smarties, for example, his article Trees in SQL.
Clint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: message board thread quandary
by shmem (Chancellor) on Sep 02, 2007 at 15:02 UTC | |
by clinton (Priest) on Sep 02, 2007 at 15:20 UTC | |
by shmem (Chancellor) on Sep 02, 2007 at 15:41 UTC | |
by clinton (Priest) on Sep 02, 2007 at 15:48 UTC |