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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.