Does Mysql 5 have procedures for managing hierarchical data?

邮差的信 提交于 2019-12-20 06:06:47

问题


I use nested set model for saving hierarchical data into database table and I'm interested in if MySQL has built-in support for adding/deleting nodes or I have to write stored procedures from scratch. Thanks.


回答1:


To my knowledge MySQL does not have an inbuilt function to do this. You may have to implement your own solution.

I have implemented nested sets with stored procedures and it worked well. I believe there has been further work on the Nested Set principle with Nested intervals to address the issues regarding the high number of updates required on the insertion or deletion of a node - but this too has its own set of problems.




回答2:


as @teabot says, MySQL doesn't ship with any inbuilt functionality to do this. However, a number of sources exist which will give you more than a half decent starting point for the queries you require, so you want have to entirely roll your own.

For examples, see Working with Graphs in MySQL , the MySQL docs and maybe even Joe Celko's book. Depending on your exact use case, you might also find that someone has done it for you (see django-mptt implementation).



来源:https://stackoverflow.com/questions/1271124/does-mysql-5-have-procedures-for-managing-hierarchical-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!