root_node

element_node

Employee

attribute_node

element_node

element_node

Proj

dept

EmpNo

 

 

 

EMPNO

 

text_node

 

 

 

 

WORKDEPT

element_node

element_node

 

ProjNo

StartDate

 

text_node

text_node

 

PROJNO

EMSTDATE

 

 

 

 

 

 

element_node

Names of columns in DB2 tables:

Name

 

 

 

 

 

 

 

 

for example, EMPNO is a column in EMPLOYEE

 

 

 

 

 

 

 

 

 

 

table in SAMPLE database

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

element_node

 

 

 

element_node

 

 

 

firstName

 

 

 

 

lastName

 

 

text_node

 

 

 

 

text_node

 

 

 

 

 

 

 

 

 

 

FIRSTNAME

 

 

 

 

LASTNAME

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 6-16 XML Collection mapping scheme

By analyzing the mapping scheme we will be able to determine whether we can compose the entire XML document with one SQL statement or not. You can use one of the two types of mapping schemes when defining a collection in the DAD file:

￿SQL mapping. SQL mapping uses SQL SELECT statement to define the DB2 tables and conditions used for composing a document from the collection.

￿RDB_node mapping. RDB_node mapping uses an XPath-based relational database node (RDB_node). The RDB_node has child elements that define the tables, columns, and conditions used to associate XML data with DB2 tables.

SQL mapping

Defining a DAD file with SQL mapping scheme allows direct mapping from relational data to XML documents through a single SQL statement and the XPath data model. When working with SQL mapping it is important to understand the following points:

￿SQL mapping scheme can be used for composition, not for decomposition.

Chapter 6. RDB and XML integration 137

Page 153
Image 153
IBM Version 5 manual SQL mapping