Querying XML Database
In the coming modules, you will learn the specifics about
- querying, and
with the information in your databases and tables. Right now, take a deep breath and realize that this is just the beginning. Think about how SQL can be used to manipulate data stored in relational databases.
An XML database is a data persistence software system
that allows data to be imported, accessed and exported in the XML format.
Two major classes of XML database exist:
- XML-enabled: These map all XML to a traditional database (such as a relational database), accepting XML as input and rendering XML as output.
- Native XML (NXD) The internal model of such databases depends on XML and uses XML documents as the fundamental unit of storage.
Note: "XML-enabled" implies that the database does the conversion itself (as opposed to relying on middleware).
XQuery, Linked Data, and the Semantic Web
If you are working with RDF, whether as RSS feeds or as Semantic Web Linked Data, XQuery has something to offer you.
You can fairly easily generate RSS and RDF/XML with XQuery, of course. The query language for RDF is called SPARQL, and there is even a SPARQL query processor written in XQuery that turns
out to be faster than many native SPARQL engines. SPARQL engines can produce results in XML, and that too can be processed with XQuery. XML and RDF both have their separate uses, as do SPARQL and XQuery, and you can use them
together when it makes sense.
- XQuery is a W3C-standardized language for querying documents and data.
- XQuery operates on instances of the XPath and XQuery Data Model, so you can use XQuery to work with anything that can build a suitable model. This often includes relational databases and RDF triple stores
- Objects in the data model and objects and values created by XQuery expressions have types as defi ned by W3C XML Schema.
- XQuery and XSLT both build on XPath; XSLT is an XML-syntax language which includes XPath expressions inside attributes and XQuery uses XPath syntax extended with more keywords.
- There are XQuery processors (sometimes called XQuery engines) that work inside relational databases, accessing the underlying store directly rather than going through SQL.
- There are also XML-native databases, and some XQuery engines just read fi les from the hard drive, from memory, or over the network.
- XQuery Update is a separate specifi cation for making changes to data model instances.
- XPath and XQuery Full Text is a separate specifi cation for full-text searching of XML documents or other data model instances.
- XQuery Scripting is a separate specifi cation that adds procedural programming to XQuery, but it is currently not a fi nal specifi cation.
- The two most important building-blocks of XQuery are the FLWOR expression and functions.
- XQuery FLWOR stands for for-let-where-order by-return.
- User-defi ned functions can be recursive, and can be collected together along with userdefined read-only variables into separate library fi les called modules.