I have a tree like graphs and I need to store them into database. I am looking for information how to efficiently store and query graphs in SQL database.
-
Highly duplicate question... Maybe pick one implementation, implement it and come back with the code to enhance the performances...pascal– pascal2010-09-27 10:34:16 +00:00Commented Sep 27, 2010 at 10:34
-
I could not find a similar question if you have one, could you include it in your comment?Skarab– Skarab2010-09-27 10:44:09 +00:00Commented Sep 27, 2010 at 10:44
Add a comment
|
1 Answer
Tree graphs, hierarchies, can be stored using the "nested set model". A web search on this term will give you a lot of good articles on this subject. The nested set model allows tree traversal without recursive queries.
The more common approach has a name, "adjacency list model". This approach does require either recursion or DBMS specific extensions to SQL.
The advantage of adjacency lists lies in fast and easy updates. The advantage of nested sets lies in easy queries.
1 Comment
CurtainDog
For a good discussion of these see techportal.ibuildings.com/2009/09/07/…