如何在SQL数据库中存储树 [英] How to store a tree in SQL database

查看:135
本文介绍了如何在SQL数据库中存储树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将一棵树存储在数据库中,那么执行此操作的最佳方法是什么?显示您使用的方法并说明其优缺点. (我正在使用SQL Server 2005)

I have to store a tree in a database, so what is the best way to do this? Show the method you use and name its pros and cons. (I am using SQL Server 2005)

推荐答案

我在 SQL反模式非常有用,因为它也着重于每种实现的弊端.

I found the discussion in the SQL Anti-patterns very helpfull, as it also focuses on the drawbacks of every implementation.

此外,此演示文稿中的幻灯片48-77重申 analisys.

Also, The slides 48-77 in this presentation reiterate that analisys.

最重要的是,没有通用树之类的东西,也没有SQL树的灵丹妙药. 您将不得不问自己有关数据的问题,如何选择和修改它们以及将如何移动它们,将分支移动到其他位置等等,并根据这些答案实施合适的解决方案.

Bottom line, there is no such thing as a generic tree, and no silver bullet for SQL trees. You'll have to ask yourself about the data, how and how much will they be selected, modified, will branches be moved around, etc, and based on those answers implement a suitable solution.

这篇关于如何在SQL数据库中存储树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆