XML Standards – XQuery vs SQL/XML

XQuery and SQL/XML are two standards that use declarative, portable queries to return XML by querying relational data. In both standards, the XML can have any desired structure, and the queries can be arbitrarily complex. XQuery is XML-centric, while SQL/XML is SQL-centric.

What are these new XML standards?

XQuery is a standard XML query language defined by the World Wide Web Consortium. XQuery allows you to work in one common model no matter what type of data you're working with – relational, XML or object data. XQuery is ideal for queries that must represent results as XML, to query XML stored inside or outside the database, or to span relational and XML sources. The XQuery API for Java (XQJ) standard (JSR 225), being developed under the Java Community Process, is designed to support the XQuery language, just like the JDBC API supports the SQL query language. XQJ is based on the XQuery Data Model rather than the relational model. It allows a Java application to submit XQuery queries to data sources and process the results.

SQL/XML is an extension of SQL that is part of ANSI/ISO SQL 2003. It lets SQL queries create XML structures with a few XML constructor functions that can be used in the SELECT clause. For a SQL programmer, SQL/XML is easy to learn because it involves additions to the existing SQL language. Also, SQL is a mature language, and there are a lot of tools and infrastructure for SQL. For instance, SQL/XML uses JDBC to return results.

Why do we need standards for XML and databases?

Most web applications have connections to databases and use XML to transfer data from the database to the web application and vice versa. Every major database vendor has proprietary extensions for using XML with relational databases, but they take completely different approaches, and there is no interoperability. Many developers need to be able to write applications that work for databases from multiple vendors.

On web pages, XML is useful because the structure of XML closely matches the structure of HTML. If you look at web pages, they often use a distinctly hierarchical structure to present data for users - after all, users don't want to look at a bunch of tables and do joins in their head. But most of the data for these web pages comes from relational databases, and needs to be converted for presentation to the user.

For web messages, the format of a web message is often specified by a standards organization or a trade partner, and these formats are generally hierarchical. Again, the data for a web message generally comes from relational data, and the consumer of a web message often needs to put data into a relational database.

The Power of XQuery

When comparing XQuery and SQL/XML, XQuery goes above and beyond SQL/XML for several reasons. The XQuery language is XML centric – XQuery code is straightforward and flexible and produces any XML structure. As compared to SQL/XML, XQuery is far less code to write and maintain for the resulting XML – providing a faster time to application deployment and less maintenance cost. XQuery doesn’t care what the data source is – any XML document, web service, relational data, and more - while SQL/XML is limited to querying only relational data. XQuery provides performance and scalability at an enterprise application level that SQL/XML can not support.

Moving Beyond SQL/XML

All XQuery implementations are not created equal. While the XQuery standard was defined to be data source independent, developers are limited to the data sources supported by their XQuery engine. DataDirect XQuery excels at performance, scalability, stability, and it's easily embedded and standards compliant. DataDirect XQuery is a well supported, robust, commercial XQuery implementation for XML that works for very large XML files (+50GB), relational databases, EDI and other legacy data sources, and more. To get started with XQuery, download DataDirect XQuery today.

Buy DataDirect XQuery®!

If you've watched our online video tutorials, read about DataDirect XQuery®'s extensive features, and tried our free download, you're ready to purchase DataDirect XQuery®.

Our buying page answers any questions you have about ordering, purchasing, and obtaining support for your copy of DataDirect XQuery®.

Back to School with DataDirect XQuery®

Getting your mind around the possibilities of a data integration technology as promising as XQuery can be difficult, but our XML developers Webinars will help you understand the power and versatility of XQuery, and our favorite XQuery processor, DataDirect XQuery®.

Stay Informed!

XQuery is one of the hottest XML technologies being developed today. Stay informed with vital news about standards, tools, and trends by signing up for the DataDirect XQuery® newsletter.