DB2 XML Extender consists of a set of stored procedures, user defined types and user defined functions that enable an application programmer to store and retrieve XML data using DB2. XML Extender uses an XML document format called Document Access Definition (DAD) to define the mapping between XML and relational data. XML Extender allows for the storage and retrieval of XML documents using one of two methods: the XML column access method, and the XML collection access method.
The XML column access method stores XML documents intact, stored as tagged data, and can optionally index the documents in side tables. The XML collection access method stores decomposed XML documents as a collection of rows in tables using traditional relational data types.
The Document Access Definition (DAD) file is an XML document that provides control over the mapping of XML documents to a DB2 database for both storage and retrieval. The DADX file is an extension of the XML Extender DAD file and includes standard SQL functionality that does not use the XML Extender. DADX enables the creation of Web services that store and retrieve XML documents managed by XML Extender. A DADX file specifies how to create a Web service using a set of operations that are defined by SQL statements, and optionally DAD files.
With DB2 version 8.2 and later there is the possibility to have the database operations that implement the web service statically stored on the application server or to have the client dynamically determine which database operation should be executed. The dynamic execution of database operations by the client is called Dynamic Query service (DQS). For a DQS service the DADX file only contains a DQS tag and no other operations. The WSDL for all DQS services regardless of which database it uses are the same. This service provides a lower level access to databases similar to JDBC and ODBC. The operations of this service are to get metadata, to execute selects, insert, updates and deletes and stored procedures.
Both XML-based and SQL-based operations are controlled by a file called a DADX. The DADX defines the operations that can be performed by the Web service. The DADX file drives the Web services run-time environment, which includes various database management tools and the Web Object Runtime Framework (WORF). The WORF runtime environment provides a simple mapping of XML schema to SQL data types. The DADX file can contain standard SQL statements, such as SELECT, INSERT, UPDATE, DELETE, and CALL statements to query and update a database and call stored procedures. If you want to process SQL statements at runtime, then you must enable the dynamic query service (DQS) that is provided by WORF by using a DADX file that includes only the <DQS/> tag.
For static DADX files the following types of Web service operations are supported:
XML-based operations include:
- query
- storage
An XML-based query enables you to compose XML documents from relational data. An XML document is broken down into its component parts and stored in relational tables. A mapping file, called a DAD file, creates the association between the relational data and the XML document structure. The user-defined mapping of SQL data to XML elements and attributes requires DB2 XML Extender.
SQL-based operations include:
- call stored procedures
- insert
- update
- delete
- query
SQL-based query allows you to send SQL statements, including stored procedure calls, to DB2 and to return the results with a default tagging. SQL-based operations do not require DB2 XML Extender since there is no user-defined mapping of SQL data to XML elements and attributes. Data is returned using only a simple mapping of SQL data types, using column names as elements.
The DADX file can also contain DB2 XML Extender elements, such as Document Access Definition (DAD) file references, XML collection operations to generate and store XML documents, or user-defined types (UDT), and user-defined functions (UDF). The DAD file defines a mapping between XML and relational data. DB2 XML Extender allows XML documents to be stored intact, and optionally indexed in side tables. DB2 XML Extender does this by using the XML column access method, or as a collection of relational tables by using the XML collection access method.
The following diagram illustrates the relationship between XML Extender, DAD, and DADX:
Figure 1. Relationship between XML Extender, DAD, and DADX.