Results 1 to 5 of 5
May 2, 2003, 17:57 #1
Saving a tree structure in a database.
In case this is relevant, I am using MS SQL.
I have my site organized in a tree structure. Let's just say each row contains the following information.
ID | Name | ParentID | Permissions
Where the Permissions colomn contains permissions for the associated node in the tree.
Now, when I load a node, I want to lead the node's parents, and so forth up to the root. Because not all permissions will be set in the permissions column for every node, and any permissions that aren't set need to be fetched from the parent node and so forth.
So, I figure I need to select the necessary node & all the parents. Is there a way to do this in one query? What would be the best way to do it?Ohai!
May 2, 2003, 18:50 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 52 Post(s)
- 2 Thread(s)
May 3, 2003, 17:42 #3
ooo... maybe I should actually start looking at the articles published here again
I probably should really improve my SQL skills... specifically my MS SQL skills.
What are some good ways to really learn this? Are there any good books or online resources?Ohai!
May 8, 2003, 05:02 #4
- Join Date
- Jan 2001
- Milton Keynes, UK
- 0 Post(s)
- 0 Thread(s)
If you want to do it in a single query Microsoft have got an article on doing this for child descedants. The query is fairly easy to modify to get the parent ancestors instead.
MSDN: Expanding Hierarchies
May 8, 2003, 06:36 #5
thanks for the link...
ok.. I really need to read up on MS Sql... I really don't know databases that well. I can barely follow the article. Does anybody know any good ways to learn how to "master" MS SQL? Book? Site? Anything?Ohai!