XML for databases: a dead idea
lemire.me
lemire.me
Believe it or not it was extremely fast...but only after playing with the xml format for awhile and making sure the indexes all fit nicely. You can, almost surprisingly, index specific XML fields inside of xml data-type columns[2].
I can almost hear you all cringing after reading that :)
[1] http://msdn.microsoft.com/en-us/library/ms190936(v=sql.90).a... [2] http://msdn.microsoft.com/en-us/library/ms191497(v=sql.90).a...
Though if you were using Postgres instead of MSSQL, you would probably consider JSON (or HSTORE) instead of XML since Postgres 9.2 has a built-in JSON column type.
That put us off the above pretty sharpish.
1- http://www.irs.gov/uac/Modernized-e-File-(MeF)-Program-Infor...
2- http://www.service-architecture.com/xml/articles/oil_and_gas...
Presumably XML is good for "interchange" but I've never found that to be the case. JSON seems to do just fine. :)
It's not; they are as well many rants about using it as a data interchange format, 'cause pretty much everything, from S-expressions to JSON, is better at this task.
XML changed things, because it shifted focus from syntax and parsing to the actual meaning of the document. It's easy now to say XML sucks, but having a standard format (that was self-documenting, too) that _everyone_ jumped on, is a major jump.
Go look at RFCs for HTTP or SIP and see how idiotic it is to have to parse yet another custom format with all sorts of cutesy exceptions. XML eliminates that. Can it be done better? Now, sure.
But from the article:
"When XML was originally conceived, it was meant for document formats. And by that standard… boy! did it succeed! Virtually all word processing and e-book formats are in XML today."
Document formats is a large, important area of technology. I suppose each of us can decide if that means XML's glass is half-full, or half-empty.
Some warped sense of ease from using Java and .NET libraries to read / write XML?
One of my favorite sayings is still "XML is like violence. If it does not solve the problem, you are not using enough."
For me, it was either use an off the shelf parser or write my own. The config files at the time were all like apache's config - various combinations of weird syntax.
XML came with parsers off the shelf and gave you some validation up front. If there were other tools at the time available, I probably hadn't found them, and XML had a lot of buzz so it was easy to find.
These days all the libraries have parsers for a variety of easy to use data formats, from JSON and YAML to Protobufs and ini files.
XML is also very ubiquitous in library support, having been around for over 15 years.
I think the most negative reaction to XML is the extreme overuse for things like component configuration, where there's no defaults, and every property and class name must be specified. Also, the misguided tag closing (<tag>content</> would have sufficed) adds to the verbosity.
1: https://plus.google.com/118095276221607585885/posts/RK8qyGVa...
Urgh... maybe the data I have had the misfortune of working with are not exercising the proper options. The ratio of metadata to data always seems too high.
Overuse is likely the cause of my dislike.
Except where the database is used to index a collection of XML data. E.g. we store dependency graphs (the output of a natural language parser) in an XML database (Berkeley DB XML), which allows us to quickly select a subset of interesting parses using XPath queries.
Sure, we could use a different storage format and query language. But there are good XML databases and XPath is well-known and standardized. The actual XML is normally only touched by machines.
An XML database is just a document store, and that idea has not died. You can s/XML/JSON/g and you'll see that the ideas and research is still very relevant today.
XML databases are decidedly 'NoSQL'. MongoDB is a good example of a straight port of the document store idea to JSON.
MongoDB would be a lot richer if it were to support XQuery in some form, rather than their awkward json querying system.
I think there is a discrepancy between the academic world which likes the orderly nature of XML and the pragmatic programmers world who like the terseness of JSON.
As to reasons for their "death": DTDs and XSDs were a serious PITA. XML data types didn't map closely to standard relational DB types; this wasted space (which was costly at the time), and made it difficult to interact with a relational DB when that was necessary. The XQuery query planner was braindead. That was really the nail in the coffin.
All in all, they're just document stores, and those are more popular than ever now with the whole NoSQL thing. As the author mentions, XML seems to have won out as a document format... I wonder what sort of DB we could put all those documents into. One that could support storing those documents without a bunch of translating to other formats, and had some method of running queries over them (preferably in a standardized way), and output the data in a similar format. Too bad XML databases are dead, one of those would have worked pretty well.
Case in point: we can dump an entire client's data from our system into a single gzipped XML blob straight from the ORM. This can also be restored straight back into the ORM as well with very little code.
This means we can switch database engines, do snapshots, backups, manage on site deployments and all sorts of nice things very easily.
You can see how popular it was considering their web site was (c) 2001 - 2003...
"I initially wanted to write an actual research article to examine why XML for databases failed [but the article would] be unpublishable because too many people will want to argue against the failure itself. This is probably a great defect of modern science: we are obsessed with success and we work to forget failure."
http://lemire.me.nyud.net/blog/archives/2013/01/14/xml-for-d...
What?
Storing the XML in a column, that's just dumb. If I did that I would only ever treat it as a binary blob, same as any file. When you start using the db's XML query support to query that column, that's when you get into trouble and need to rethink your design.
Relational means something that accepts Codd's constraints, more-or-less. Pointer is something that doesn't, and which therefore easily allows hierarchies.
Logical is like relational, expanded to allow recursive queries, prolog-style, which is a high level way to have hierarchies and Codd's constraints, but you pay for in terms of query performance.
The thing is, pointer databases have been reinvented again and again: First as the mainframe cobol databases of the 70s, then as the filesystem, then as the windows registry, then as OODBMSs, then as XML databases, and now as NoSQL.
The other thing is, Postgres is designed to cater for all 3, relational, pointer and logical.
Use the best tool for the job and all that.
I don't know of anyone advocating that they something other than the best tools for the job should ever be used. The question is whether a particular tool is good for a particular job or not.