Generating a DAD File for IBM DB2

IBM DB2 v8.1 (or higher) is a database server with an add-in for XML storage and retrieval called IBM DB2 Extender. XML data (elements, attributes) are mapped to relational data (tables, columns) through Document Access Definition files (.DAD).

There are three types of DAD files:

Storage Type

Description

Xcolumn

Column mapping - the Root element is mapped to a table, and its attributes or child elements are mapped to columns identified by an XPath

Xcollection

SQL mapping - the DAD file starts with a SQL statement for the table mapped to the Root element, and each child element or attribute is mapped to a column or a table name

Xcollection

RDB mapping - a Relational Database node, with a table and a column name, is associated with each attribute or child element of the Root element

An XML model targeted with DTD allows you to generate DAD files for IBM DB2.

  1. Map an XSM to a PDM. You can do this manually or by generating an XSM from a PDM (or a PDM from an XSM).
  2. To enable the IBM DB2 DAD extensions in your model, select Model > Extensions, click the Attach an Extension tool, select the IBM DB2 DAD file (on the XML in Database tab), and click OK to attach it..
  3. [optional] Set extended attributes on global elements to reinforce their mapping to tables and columns The following properties are listed on the Extended Attributes tab:

    Extended attribute

    Description

    Database

    Name of the database

    DTDID

    ID added to the DTD_ref system table in DB2 XML Extender

    Login

    Name of the logged-in user

    MappingType

    Type of mapping for a collection

    NamespaceNode

    Text zone where each line describes a namespace couple (name = value). The separator character is '='

    Password

    Password of the logged-in user

    PathGeneration

    Generation path

    ProcessInstruction

    A text zone that enables the user to enter some instruction

    SideTableID

    Identifier of the side table (optional)

    SideTableName

    Name of the side table

    StorageName

    If StorageType is Xcolumn, then it is the name of the sidetable column

    StorageType

    Type of storage (Xcollection or Xcolumn)

  4. [optional] Click the Preview tab of the Root element property sheet, and select the DB2XMLExtender.DAD File tab to preview the DAD file. If the DAD File tab is not available, click the Select Generation Targets tool to select IBM DB2 DAD in the Targets list and click OK.
  5. Select Language > Generate schemaFile to open the Generation dialog box.
  6. Specify the directory in which to generate the file and select the XML in Database target on the Targets tab.


  7. [optional] Click the Options tab, and set any appropriate generation options:

    Option

    Description

    Character ending an instruction

    Character ending instructions in the SQL file for stored procedures

    Generates procedures deployment

    Generation of a SQL script for stored procedures enabling XML data storage and facilitating XML data retrieval

    Path of DAD.dtd

    Path of the DTD file installed with IBM DB2 Extender and describing the specific syntax of DAD files

    Schema validation

    Validation tag in the DAD files to check the conformity of DAD files with the DAD syntax

  8. Click OK to begin the generation.

    The Result dialog box is displayed with the path of the generated DAD, DTD and SQL files.

  9. Click Edit to open the generated DAD file in your associated editor:
    • Extract of a DAD file defined with Xcollection as StorageType, and RDB as MappingType:



    • DAD file defined with Xcolumn as StorageType: