开发者

What are the common issues surrounding storage of XML data in a relational databases?

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"?


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".


One problem with supporting XML in an RDBMS is that there are AFAIK no universally accepted rules for comparison of XML documents. A relational database can in principle store any attribute value that can support assignment and comparison - this being essential to relational projection for example because the values of each attribute must be comparable to each other. Comparison is no problem for most types: strings, numbers, binary etc. It's potentially more difficult for a XML document type.

Some SQL DBMSs (ie non-relational DBMSs) simply don't permit comparison of XML values at all. For instance Microsoft SQL Server allows XML-typed columns but they cannot be compared and so among other things SELECT DISTINCT is not supported.


it actually depends on what kind of data you are storing in your DB, its normal for exemple to store XHTML information on the database.. one of the principes of a relational database is that the information is atomic, i mean, you should store something like

name    |   professions
----------------------
Clark   |  writer, journaliste, superhero

so i'd be against to store something like

name    |   information
----------------------
Clark   |  <profession> writer </profession><profession> journaliste </profession><profession> superhero </profession>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜