Introduction
XML in DB2 UDB Version supports DB2-based relationship infrastructure. XML data is either stored as a character large object (CLOB) or broken down into a relational table. DB2 UDB Viper, on the other hand, has real XML data native support. Now, XML data is processed as a new data type and stored in a parsed and commented tree, separate from the relational data store. XML indexing technology based on XML schema is also introduced, and XQuery and SQL/XML are supported as languages for querying and publishing XML data.
XML support in DB2 UDB Version
DB2 uses SQL/XML and DB2 XML Extender to provide XML functionality to underlying relational data. DB2 XML Extender provides many user-defined types (UDT), user-defined functions (UDF), and stored procedures to support XML. XML documents are stored in relational form and use the XML Extender infrastructure to provide XML representations for relational data. There are also support for some SQL/XML functions used to publish relational data as XML. More details can be found on the DB2 XML Extender Web site.
DB2 also allows the creation of user-defined Java functions and stored procedures that can merge XML and XSL parsers (installed as part of DB2) into the code.
XML support in DB2 Viper
DB2 Viper supports native XML storage, eliminating the need to break XML into relational tables for query and publication. This new storage method saves XML into a parsed and commented tree form similar to the XML Document Object Model (DOM). For applications that still need to decompose XML data into relational tables, this release also provides enhanced decomposition functionality using annotated XML schema mapping.
XML Feature Comparison — DB2 UDB Version and DB2 Viper
Table 1. XML Feature Comparison — DB2 UDB Version and DB2 Viper
DB2 UDB Version
DB2 Viper
Storage and indexing
XML data storage is in two forms:
Documentation as is:
- XML Extender columns of XMLCLOB, XMLVARCHAR, XMLFILE types.
- A column of type BLOB, CLOB, or VARCHAR.
- Create an indirect index of the XML document in the relationship secondary table.
- Parses the document to update the created secondary table.
- Use Document Access Definition (DAD) to decompose into existing relationship tables.
- Only leaf nodes in XML can be decomposed and mapped to SQL column types.
- Namespaces are not supported.
- Limited functionality and cannot handle complex XML documents.
As-is native document XML storage.
- A brand new hierarchical (native) storage is built from scratch. This storage method saves any tree form of the document.
- Column of type XML.
- Create an XML index using the path expression of the leaf node.
- Parse the document when inserting.
- Use annotated XML schema mapping to decompose to existing relationship tables.
- XML fragments can also be decomposed and mapped to XML column types.
- Handle namespace.
- Extended functions can be used to filter XML data, such as DB2 expressions and conditions.
- Implicit verification defined in DAD.
- Use XML Extender UDF svalidate for explicit verification.
- Document Type Definition (DTD) is registered and stored in an internal table.
- Obtain XML schema from the file system.
- There is no implicit validation associated with the column.
- Use the SQL/XML function XMLVALIDATE for explicit verification.
- DTD verification is not supported.
- DTD and XML schemas are registered in the XML schema repository (XSR) and stored in the database.
Use SQL/XML and XML Extender functions for querying and publishing.
For the same-is XML document.
- Use the indexed secondary table to query the document and obtain the document in CLOB.
- Subdocument query can be used using the XML Extender function.
For XML data decomposed into relational tables.
- SQL/XML Publishing Functions.
- XML Extender DAD maps and functions.
For the same-is XML document.
- A mix of SQL/XML and XQuery can be used to retrieve and publish relational and XML data.
- Multiple XML columns can be joined.
- XML can be queried, transformed, and published using XQuery.
- SQL/XML Publishing Functions.
- Use SQL update statements to perform full document updates.
- Update using XML Extender UDF update.
- Use SQL update statements to perform full document updates.
- Subdocument updates are not supported due to the lack of standards that define XQuery updates.
- To download the updated stored procedures from developerWorks, see XML application migration from DB2 to DB2 Viper, Part 1: Partial updates to XML documents in DB2 Viper (developerWorks, May 2006).
Websphere Studio Application Developer
- XML Schema Editor
- DTD Editor
- DAD Mapping Tools
- SQL XML is not supported in the query builder.
- Xerces and Xalan parsers
- Support is not available in the Java Database Connectivity (JDBC) driver.
DB2 Control Center and DB2 Develope
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] Next article