Document Access Definitions (DAD)

The Document Access Definitions file, itself an XML formatted document, is used to associate the XML document structure to a DB2 database. Basically, it provides the mapping between the elements or attributes of an XML document and the table columns, and the details of how a request for an XML document is to be handled.

The DAD file answers questions like:

￿If the document is to stored in the database, then will it be stored as is, that is, the complete document in a table column or not? If so, then do you need any indexes built on the elements/attributes that are most frequently used as search parameters?

￿Do you need to break up the elements/attributes of the xml document and keep them in separate tables? If so, then which tables will participate in the decomposition process?

￿Do you want to compose an xml document from data in DB2 tables? If so, then the tables that will provide the elements/attributes and so on.

The structure of the DAD file depends on whether you are defining an XML Column or Collection. For now, we will mention that the XML Column stores the entire XML document as is, while the XML Collection takes the elements or attributes from the XML document and stores them in separate tables or columns.

The DAD file conforms to the DTD provided in the DAD.dtd file is located in the dtd subdirectory of the XML Extender install directory. In the case of Windows NT or Windows 2000, it is "<drive-letter>:\<installation path>\dxx\dtd\DAD.dtd".

The XML Extender manages the DAD files with the administrative support table XML_USAGE. This table is created when a database is enabled for XML. For example, the DAD file that maps the element ’title’ from the DTD in Example 5-2 to a table column using the XML Column method is shown in Example 5-3:

Example 6-12 DTD representation of a book

<!ELEMENT redbook (title, subject, pubdate, leader, author*)> <!ATTLIST redbook isbn ID CDATA #required>

<!ELEMENT title (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT pubdate (#PCDATA)> <!ELEMENT leader (#PCDATA)>

<!ELEMENT author (authorname, authorloc)> <!ELEMENT authorname (#PCDATA)> <!ELEMENT authorloc (#PCDATA)>

Chapter 6. RDB and XML integration 131

Page 147
Image 147
IBM Version 5 manual Document Access Definitions DAD, Example 6-12 DTD representation of a book