关于从这个问题开始的讨论,我决定将其作为一个社区维基问题。
因此,问题的根源是将XML数据存储在关系数据库中是否合适? 通常有更好的方法来实现相同的目标吗? 哪些数据库引擎为XML数据类型(如SQL Server)提供了良好的支持,以及围绕所谓的“XML索引”的问题是什么?
In relation to a discussion started at this question, I've decided to put this up as a community wiki question.
The root of the question is, therefore, is it appropriate to store XML data in a relational database? Are there generally better ways to implement the same goal? What database engines provide good support for XML data types (such as SQL Server), and what are the issues surrounding so-called "XML indexes"?
最满意答案
数据库用于存储数据。 XML就是数据。 因此,在适当的情况下,将XML存储在数据库中是完全有效的。 这是否是最有效的事情取决于许多可能无法概括的因素。
例如,如果您有一个表示对象的结构化XML文档(例如:书店中的一本书),那么解析数据并将其存储在为该数据设计的数据库中的适当行和列中可能是有意义的。
OTOH,想象一个包含代码示例的数据库。 您有语言,说明和代码的列。 对于XML,显然您将XML存储在代码列中。
所以,像软件中的许多东西一样,“它取决于”。
Databases are for storing data. XML is data. Therefore, under the right circumstances it's perfectly valid to store XML in a database. Whether that's the most efficient thing to do depends on a lot of factors that probably can't be generalized.
For example, if you have a structured XML document that represents an object (eg: a book in a bookstore), it likely makes sense to parse the data and store in in appropriate rows and columns in a database designed for that data.
OTOH, imagine a database holding code samples. You have columns for language, description, and the code. In the case of XML, obviously you'll store the XML in the code column.
So, like so many things in software, "it depends".
更多推荐
发布评论