Jump to content

XML database

From Wikipedia, the free encyclopedia

Template:Short description Template:Update

An XML database is a data persistence software system that allows data to be specified, and stored, in XML format. This data can be queried, transformed, exported and returned to a calling system. XML databases are a flavor of document-oriented databases which are in turn a category of database.Relational database management systems continue to support XML storage and processing alongside relational data. For example, Microsoft SQL Server supports an XML data type and XML schema collections, which can be used to validate XML documents and provide type information for stored data.[1]

Rationale for XML as a database format

Reasons to store data in XML format as an XML database include:[2][3]

  • An enterprise may have numerous XML documents with similar data, but dispersed in different XML formats. Conglomerating this data into a singular, standardized XML database structure will avoid compatibility issues
  • Data may need to be exposed or ingested as XML, so using another format such as relational forces double-modeling of the data
  • XML is very well suited to parse data, deeply nested data and mixed content (such as text with embedded markup tags)
  • XML is human readable whereas relational tables require expertise to access
  • Metadata is often available as XML
  • Semantic web data is available as RDF/XML
  • Provides a solution for Object-relational impedance mismatch[4]
  • Compatibility with XML use on the data transport layer

XML-enabled databases

XML-enabled databases typically offer one or more of the following approaches to storing XML within the traditional relational structure:

  1. XML is stored into a CLOB (Character large object)
  2. XML is "shredded" into a series of tables based on a schema[5]
  3. XML is stored into a native XML Type as defined by ISO Standard 9075-14[6]

RDBMS that support the ISO XML Type are:

  1. IBM DB2 (pureXML[7])
  2. Microsoft SQL Server[8]
  3. Oracle Database[9]
  4. PostgreSQL[10]

Typically an XML-enabled database is best suited where the majority of data are non-XML. For datasets where the majority of data are XML, a native XML database is better suited.

Example of XML Type Query in IBM DB2 SQL

<syntaxhighlight lang="sql"> select

  id, vol, xmlquery('$j/name', passing journal as "j") as name 

from

  journals

where

  xmlexists('$j[licence="CreativeCommons"]', passing journal as "j")

</syntaxhighlight>

Native XML databases

Native XML databases are especially tailored for working with XML data. As managing XML as large strings would be inefficient, and due to the hierarchical nature of XML, custom optimized data structures are used for storage and querying. This usually increases performance both in terms of read-only queries and updates.[11] XML nodes and documents are the fundamental unit of (logical) storage, just as a relational database has fields and rows. One important caveat to this is that native XML databases need more disk space to store both data and indexes than XML-enabled databases do. As the size of the native XML database grows, the storage needs grow almost exponentially.[12]

The standard for querying XML data per W3C recommendation is XQuery; the latest version is XQuery 3.1.[13] XQuery includes XPath as a sub-language and XML itself is a valid sub-syntax of XQuery. In addition to XPath, some XML databases support XSLT as a method of transforming documents or query results retrieved from the database.

Language features

Template:Sort-under

Name License Native Language XQuery 3.1 XQuery 3.0 XQuery 1.0 XQuery Update XQuery Full Text EXPath Extensions EXQuery Extensions XSLT 2.0 XForms 1.1 XProc 1.0
BaseX Template:BSD-lic Java Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes Template:No
eXist Template:LGPL-lic Java Template:Partial Template:Partial Template:Yes Template:Proprietary Template:Proprietary Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes
MarkLogic Server Template:Proprietary C++ Template:No Template:Partial Template:Yes Template:Proprietary Template:Proprietary Template:No Template:No Template:Yes Template:Yes Template:No
OpenText xDB Template:Proprietary Java Template:Partial Template:Partial Template:Yes Template:Yes Template:Yes Template:No Template:No Template:No Template:No Template:No
Oracle Berkeley DB XML Template:Proprietary C/C++
Qizx Template:Proprietary Java Template:No Template:No Template:Yes Template:Yes Template:Yes Template:No Template:No Template:Yes Template:No Template:No
Sedna Apache License 2.0 C/C++

Supported APIs

Name XQJ XML:DB RESTful RESTXQ WebDAV
BaseX Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes
eXist Template:Yes Template:Yes Template:Yes Template:Yes Template:Yes
MarkLogic Server Template:Yes Template:No Template:Yes Template:Yes Template:Yes
Qizx Template:No Template:No Template:Yes Template:No Template:No
Sedna Template:Yes Template:Yes Template:No Template:No Template:No

References

Template:Reflist

Template:Database models Template:Databases

  1. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  2. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  3. ↑ Template:Cite conference
  4. ↑ [NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence. Addison-Wesley Educational Publishers Inc, 2009] Template:ISBN
  5. ↑ Template:Cite book. Section Creating XMLType Tables and Columns Based on XML Schema
  6. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  7. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  8. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  9. ↑ Template:Cite book
  10. ↑ Template:Cite book
  11. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
  12. ↑ Template:Cite journal
  13. ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}