Getting a grip on XQuery

07.12.2006

One company that uses our [DataDirect] XQuery product has salespeople go out to sell an HR outsourcing service. They have an Oracle database with information on their customers, along with Salesforce.com. The sales rep tells the customer they can do their HR cheaper than their in-house guys, so he performs this query, gets the data from different data sources and then creates a PDF document with the information, which is basically their sales offer.

Let's say you've already got an electronic data interchange system. Wouldn't you rather just keep data in that format and forego XML and XQuery? If your system is using only one kind of data format and doesn't need XML, there's not a lot of advantage to bringing in XQuery. The best example is a relational table. If you're querying it in order to create tables, then there's no need for XQuery. But if you're querying it to create XML, XQuery will save you a lot of effort.

So XML and XQuery don't make relational databases and SQL redundant? Relational databases are certainly here to stay. It's an established technology, and things that are so useful rarely die. But all relational databases are becoming compound databases. Because if you are doing Web services, Web sites, Web publishing, XML is the format in which your data moves around.

Still, are relational vendors feeling at all threatened by XML and XQuery? Oracle, Microsoft and IBM have all invested heavily in XQuery. IBM is seeing this as a major competitive thing. You also see it in application server environments like BEA. There are 40-odd implementations of XQuery now, and I'd say a good dozen or so are serious at this point. I think you can't go to a relational database conference without hearing about XQuery. If you look at all of the things you want to do to establish mind share, XQuery can check off all the boxes.

What is the difference between XQuery and some other XML languages I have heard about, such as XSLT or XPath? Is XQuery better? XPath is a subset of XQuery. It is a way of pointing to something in an XML document. XQuery uses it. XSLT -- that's a more complicated relationship. Both languages have the same foundation, are built on the same data model. XSLT was designed as a style-sheet language, a way to display something as HTML, PostScript or PDF. You could do that with XQuery, but XSLT is a better tool for that. If you want a language to be implemented for a variety of data stores, for data integration, XQuery is better designed.