Wednesday, June 5, 2013

Native XML Support

DB2 now allows for unstructured XML data to be stored natively alongside structured relational data in a DB2 table via DB2’s “pureXML” technology.

Among the capabilities provided by pureXML in DB2 are:
  • A native XML data type
  • SQL/XML language, which provides full XML functions within the SQL language to access XML structures
  • Hybrid data access, in which both XML and relational data can be accessed together in a single SQL/XML statement
  • Read and write access to XML documents and sub-documents
  • XML indexes to provide efficient access paths to XML data stored within a DB2 table
  • XML schema validation against an XML schema that is registered in the Schema Repository, including support for multiple versions of an XML schema
Collectively with these capabilities, DB2 becomes a repository for native storage of both relational and XML data, thus making DB2 a hybrid database server.
Prior to the introduction of pureXML technology in DB2, XML data could be stored in a DB2 database, but it would have to be stored either as an unformatted string in a CLOB data type column, or it would need to be “shredded” into individual elements that would then be stored in traditional relational columns.
If XML data was stored within a CLOB data type, then DB2 had no understanding of the structure of the XML document it was storing, and searching on components of an XML document meant that the entire document would need to be retrieved and parsed. This could be an expensive operation in terms of CPU resources. If the XML document was shredded into individual elements that were stored in traditional relational database columns, then all the inherent advantages and integrity of the original XML document would be lost.
With native XML storage, XML data can be searched on and retrieved efficiently without having to lose any of the integrity of the XML document itself.
The SQL/XML language that is introduced with pureXML allows for individual elements of an XML document to be inserted, updated and deleted. Stored XML documents can also be indexed for efficient searching and retrieval of data, in much the same way that relational indexes are used for traditional relational data in a DB2 table.