- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI'm trying to find ideal solution to store a tree structure. Each node has a name. Constraint is that there may not be two same named nodes having same parent. Is it possible to select node using path to node(?) - /a/b/c will select node named 'c' that is children of node named 'b' that is chilren of node named 'a';
I have found two solutions on this topic - adjacency list, nested sets. But don't know if it's possible to perform selection using path to node like described above.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: NovaDenizenPosted on 2005-03-17 at 07:16:49ID: 13565620
One way to jump straight to a node is to store the full path to the node in each node. i.e. Every node contains a path varchar, nodename varchar and you make an index on (path, nodename).
If that path varchar takes up more space than you're willing to use, you could instead store a hash of the path in each node. Each node would contain a pathhash bigint, and a nodename varchar and you make an index on (pathhash, nodename). The problem with this approach is that you will occasionally (but not very often) have a hash collision and the query will return more than one node. In this rare case you would have to do it manually the normal way.