我什么时候会使用 XML 而不是 SQL? [英] When would I use XML instead of SQL?

查看:29
本文介绍了我什么时候会使用 XML 而不是 SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我多年来一直致力于数据库驱动的 Web 应用程序,最近参与了一个涉及支持 XML 的 CMS 的项目.这让我开始思考 XML/XSLT 的一般用法,以及在什么情况下它比我一直使用的方法更有用,后者将我的所有数据存储在 (My)SQL 数据库中,然后使用PHP/Python/等.根据需要在网络上使用它.

I've been working on database-driven web applications for a few years now and recently took on a project involving a CMS that is XML-capable. This has led me to think about the usage of XML/XSLT in general and in what situations it would be more useful than the approach I've always used, which is storing all of my data in a (My)SQL database and then using PHP/Python/etc. to work with it on the web as needed.

显然有些东西我没有在这里得到"......谁能给我一些应用程序的例子,在这些应用程序中,将数据存储在 XML 文件而不是数据库中会更可取?

There's obviously something I'm not "getting" here.. could anyone give me examples of applications where storing the data in XML files instead of in a database would be preferable?

推荐答案

引用 本书(有效的 XML:改进 XML 的 50 种特定方法):

To quote This Book (Effective XML: 50 Specific Ways to Improve Your XML):

XML 不是数据库.从来没有本来就是一个数据库.它从来都不是将成为一个数据库.关系型数据库是经过验证的技术20多年的实施经验.它们坚固、稳定、有用的产品.他们不去离开.XML 是一项非常有用的技术用于在不同的数据之间移动数据库或数据库和数据库之间其他程序.然而,它不是本身就是一个数据库.不要像这样使用它一个."

"XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one."

我认为这就是总结,如果有点直白的话.XML 是一种数据交换格式.可以拥有 XML 解析库,可以使用 XPath 表达式查询 DOM,但这与 DBMS 不同.您可以使用 DOM/XPath 接口构建 DBMS,但要获得 ACID 属性或扩展到大型数据集,您需要实现 DBMS 引擎和具有索引、日志记录和 DBMS 其他工件的数据格式 - 这(根据定义)使得它不是 XML.

I think this sums it up, if a little bluntly. XML is a data interchange format. One can have XML parsing libraries that can query a DOM with XPath expressions but that is not the same thing as a DBMS. You can build a DBMS with a DOM/XPath interface but to get ACID properties or scale to large data sets you need to implement a DBMS engine and a data format with indexes, logging and other artifacts of a DBMS - which (by definition) makes it something other than XML.

这篇关于我什么时候会使用 XML 而不是 SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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