Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When would I use XML instead of SQL? [closed]

Tags:

sql

xml

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.

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?

like image 773
Patrick Lewis Avatar asked Oct 14 '08 15:10

Patrick Lewis


People also ask

Why are we using XML instead of database?

XML Database is used to store huge amount of information in the XML format. As the use of XML is increasing in every field, it is required to have a secured place to store the XML documents. The data stored in the database can be queried using XQuery, serialized, and exported into a desired format.

When should I use XML in SQL Server?

Support for XML is integrated into all the components in SQL Server in the following ways: The xml data type. XML values can be stored natively in an xml data type column that can be typed according to a collection of XML schemas, or left untyped. You can index the XML column.

When should I use XML?

XML is often used in front-end web development. It's also is used in back-end web development because some APIs use it to transfer data in a standard format. Android applications also depend heavily on XML to create layouts and store configurations, so you should learn XML if you're interested in mobile development.

What is the advantage of using an XML database over a relational database?

XML allows you to capture all the information about the object in one message, that's independent of the design of your database and possibly conforms to some industry standard like OTA, and load it into a different database with a quite different design.


1 Answers

To quote This Book (Effective XML: 50 Specific Ways to Improve Your 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.“

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.

like image 69
ConcernedOfTunbridgeWells Avatar answered Oct 23 '22 13:10

ConcernedOfTunbridgeWells