是否有一个数据库可以存储树结构(例如嵌套注释)而不使用反模式等。
我认为 LDAP 就是其中之一,但是还有其他的吗?
我也需要能够索引childes。我需要它能够轻松地将分支从一个节点移动到另一个节点,并且能够快速读取+格式化。
我见过其他类似的问题。那些(对我来说)的问题是,他们问在 db XXX 中最有效的方法是什么,而我则问我应该使用哪个数据库。
Is there a DB out there that can store tree structures (like for nested comments) without using anti-patterns or such.
I think LDAP is one, but are there any others?
I need to be able to index childes as well. I need it to be easy to move a branch from one node to a different node and be fast to read + format.
I have seen other similar questions. The problem with those (for me) they ask what is the most efficient way to do it in db XXX, while I ask which DB I should use.
发布评论
评论(2)
如果树很深,关系数据库将不是最好的选择。我推荐一个图形或对象数据库。
“存储评论”?喜欢以下博客或文章吗?如果是这样的话,我想说你可以假设它们不会那么深。十级评论树将是例外。
在这种情况下,使用外键的简单关系父/子关系就足够了:
Relational databases won't be the best for this if the tree is very deep. I'd recommend a graph or object database.
"Storing comments"? Like those following blogs or articles? If that's the case, I'd say that you can assume they won't be that deep. A ten level comment tree would be exceptional.
In that case, a simple relational parent/child relationship using foreign keys would be sufficient:
当然,“关系数据库”强调的是“表”(二维关系)。
RDBMS 供应商有许多不同的选择。例如,DB2 有“层次结构”,Oracle 有“层次查询”:
http://www.ibm.com/developerworks/data/library/techarticle/dm-0506melnyk/
http://www.orafaq.com/node/2038
更一般地说,大多数主要 RDBMS 产品(MS Sql Server、IBM DB2、Oracle)都已支持 XML。这提供了一种更强大、更便携的方法来操作结构化数据。
当然,在非 RDBMS 供应商中,还有更多处理非关系数据(如树)的选择。相应地,可移植性也较差——将自己锁定在一个“非 SQL 数据库”中往往会导致您无法轻松地将应用程序迁移到其他数据库。
底线:
如果您可以将 XML 与关系数据库结合使用,那么这可能是您的最佳选择。以下是一些很好的链接:
http://troels.arvin.dk/db /rdbms/links/#hierarchical
http://www.techrepublic.com/article/shred-xml-data-with-xquery-in-sql-server-2005/6140404
http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb_xquery.htm
http://www.redbooks.ibm.com/abstracts/sg247298.html
'希望这有帮助!
"Relational Databases", of course, emphasize "tables" (2-D relationships).
Among RDBMS vendors, there are many different alternatives. For example, DB2 has "hierarchical structures", and Oracle has "hierarchical queries":
http://www.ibm.com/developerworks/data/library/techarticle/dm-0506melnyk/
http://www.orafaq.com/node/2038
More generally, most of the major RDBMS products (MS Sql Server, IBM DB2, Oracle) have all become XML-aware. This provides a more robust, portable approach to manipulating structured data.
Of course, among non-RDBMS vendors, there are even more alternatives for dealing with non-relational data (like trees). Correspondingly, there's less portability - locking yourself into one "non-SQL database" more often than not locks you OUT of easily migrating your application to a different database.
BOTTOM LINE:
If you can use XML with a relational database, that's probably your best option. Here are some good links:
http://troels.arvin.dk/db/rdbms/links/#hierarchical
http://www.techrepublic.com/article/shred-xml-data-with-xquery-in-sql-server-2005/6140404
http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb_xquery.htm
http://www.redbooks.ibm.com/abstracts/sg247298.html
'Hope that helps!