Hey, I'm having trouble understanding why XML should be used instead of something like MySQL? Is there something that XML can do that an SQL database can't? Or perhaps I'm misunderstanding the use of XML. I've looked up examples of XML and I've seen an example that shows you can make a list of CD albums which can already be done by an SQL database.
What is the difference/advantage of using XML over an SQL database?
mySQL requires a database server. XML does not.
XML's only advantage that I can think of is its portability: it uses a non-proprietary file format (plain text) with a standard mark-up specification that allows any application to access the data.
A DBMS such as MySQL provides much better speed along with all sorts of built-in functions and other capabilities.
But you don't necessarily have to choose one or the other. You can store all your data in a DBMS, and then in any situation where you want to output it as XML for some other application to be able to access your data, it's really a comparatively simple process to output the selected data as a XML file.
XML is not a database server and cannot do any of the things MySQL can. XML files are not indexed and cannot be searched efficiently. XML files can't be updated efficiently. XML files take up more storage space*. XML files are complicated to work with and need careful use of synchronisation/locking to avoid data loss as there is no built-in mechanism to prevent concurrent access.
XML is not how you want to store data if you plan on accessing or changing it ever.
Mark
- In most cases
MarkR wrote:XML is not a database server
Boom! Thanks for pointing that out - Would hope it was already done by the time I got here
Do not attempt to use XML as a form of database - thats not what its designed for.
XML allows systems/websites/components to communicate over a common language.
For example, if you asked me to send you a list of my contact details, I could create an xml file:
<contact>
<name>Andrew</name>
<phone>123456</phone>
</contact>
And, even from looking at that file yourself - you can tell what the information is. You could then tell your computer to store my name in the contact/name tag of the XML file.
Whereas, if you had a file like this:
andrew 123456
You have no idea what context those values have, this is where XML is used.
You would NOT use XML to act as a database, rather, to communicate information amongst people/systems which both humans and computers may understand and is flexable.
Also, note that XML is a hierarchical data format that stores information in a tree-based manner, while a relational database - er, isn't and doesn't (it just has "tables" that represent "relations"). Just compare database manipulation operations with XML manipulation operations. (Exercise for the reader: Pick pretty much any XHTML/MathML/SVG/XUL file and try and represent its structure and content in a relational database, remembering that your implementation should also be able to store other documents that use the same XML dialect.)