XML database
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.
Rationale for XML as a database format
Reasons to store data in XML format as an XML database include:- 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
- 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
- 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:- XML is stored into a CLOB
- XML is `shredded` into a series of Tables based on a Schema
- XML is stored into a native XML Type as defined by ISO Standard 9075-14
- IBM DB2
- Microsoft SQL Server
- Oracle Database
- PostgreSQL
Example of XML Type Query in IBM DB2 SQL
select
id, vol, xmlquery as name
from
journals
where
xmlexists
Integration with relational databases
XML databases are often used in combination with relational databases to manage and store hierarchical data. A significant challenge in such integrations is extracting XML documents from relational databases, which requires specialized techniques and tools. These techniques often include:- Mapping Relational Data to XML: Schema mapping is a critical process that defines how relational tables correspond to XML elements and attributes.
- XQuery Processing: Querying XML data extracted from relational databases may involve XQuery, a language designed for querying and transforming XML.
For example, extracting hierarchical data from relational databases and converting it into XML is a common approach when generating XML feeds, exchanging data between systems, or implementing XML-based configurations.
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. XML nodes and documents are the fundamental unit of storage, just as a relational database has fields and rows.The standard for querying XML data per W3C recommendation is XQuery; the latest version is XQuery 3.1. 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
| 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 | Java | |||||||||||
| eXist | Java | |||||||||||
| MarkLogic Server | C++ | |||||||||||
| OpenText xDB | Java | |||||||||||
| Oracle Berkeley DB XML | C/C++ | |||||||||||
| Qizx | Java | |||||||||||
| Sedna | Apache License 2.0 | C/C++ |