IBM DB2 UD & XML Extender IBM DB2 UD & XML Extender AstroGrid Project Registry Group Pedro Contreras...
-
Upload
pamela-green -
Category
Documents
-
view
235 -
download
0
Transcript of IBM DB2 UD & XML Extender IBM DB2 UD & XML Extender AstroGrid Project Registry Group Pedro Contreras...
IBM DB2 UD &IBM DB2 UD &XML ExtenderXML ExtenderIBM DB2 UD &IBM DB2 UD &XML ExtenderXML Extender
AstroGrid Project AstroGrid Project Registry GroupRegistry GroupPedro ContrerasPedro Contreras
14 August 200314 August 2003
OverviewOverviewInstallation & Requirement
XML Extender
How DB2 and XML Extender work together
Storages and access methods
XML column methodXML collection method
Document Access Definition (DAD) file
Working with XML ExtenderPlanning how to store the documentSteps to enable XML extender for XML document
Mapping a DAD file: an example
Installation & Requirement
Can be installed as part of DB2 Universal Database 8.1 Or can be installed later
Requirement
- DB2ADM authority- Bind the XML Extender to your DB2 UDB database
XML Extender
- Stores and access XML documents
- Generates XML documents from an existent Database
- Inserts row into relational tables from XML documents
- It provides new data types, functions and store procedure to manage XML data in DB2
How DB2 and XML Extender work together
- Administration tools to help with the integration of XML Data with DB2- XML Extender wizard- dxxadm command line - XML Extender Store procedures
- Store and access methods for XML data within the database
- DTD (or schemas) used to validate XML data
- A mapping file called Document Access Definition (DAD), used to map XML documents into relational data
Storages and access methods
XML Extenders provides two different methods for integrating XML documents withDB2 data structures: XML columns and XML collections. These methods aredifferent but can be used in the same application.
XML column methodIt stores intact XML documents in DB2. This method works well for archiving documents. The documents are inserted into columns enabled for XML that can be updated, retrieved and searched.
XML collection methodThis method map XML document structure to DB2 tables. So, it can either compose XML documents from existent DB2 data, or decompose XML documents into DB2 tables.This method is good when the contents of XML documents are frequentlyupdated
Document Access Definition (DAD) file
It defines the locations of important files like DTD or schemas, and specifies how the XML document structure is related to DB2 data.
It also defines the access and storage method used in the application.
In short, the DAD file is an XML document that maps the XML structure to the DB2 table.
Planning how to store the document
- Understand the structure of XML document
- Identify the XML user-defined type in which you will store the XML document
- Identify XML elements that will be frequently search. The content of
these can be store in side tables and indexed to improve performance
Steps to enable XML extender for XML documents- Choose one method of mapping: XML column or XML collection
- Enable the DB to work with XML files: “dxxadm enable_db db_name”
- Store the DTD into DB2: can be done by command line or the GUI
- Create a DAD file
- Create and enable the columns to store the XML document
Working with XML Extender
<?xml?><!DOCTYPE..>
< element > . .</element >
. .<Xcollection> <table> <column> </table> . .<Xcollection>
XML Document DAD file
DB2
Mapping a DAD file
serviceMetadataConcept
interfaceMetadatacapabilitiesMetadata
serviceRestriction
serviceStandardUri
serviceStandardUrl
serviceRestrictionSpatial
serviceMaxNrows
serviceMaxImageSize
serviceMSR
serviceHTTPResultType
serviceHTTPResult
serviceInterfaceUrl
serviceBaseUrl
service.xml
Mapping a DAD file
serviceMetadataConcept
interfaceMetadatacapabilitiesMetadata
serviceRestriction
serviceStandardUri
serviceStandardUrl
serviceRestrictionSpatial
serviceMaxNrows
serviceMaxImageSize
serviceMSR
serviceHTTPResultType
serviceHTTPResult
serviceInterfaceUrl
serviceBaseUrl
StandardUri
StandardUr
MSR
MaxImageSize
httpResultType
interfaceUrl
baseUrl
MaxNrows
service.xml mapped to DB
Name of column in DB2 table
Mapping a DAD file
XML Extender Administrator LaunchPad
COM.ibm.db2.jdbc.net.DB2.Driver (network connection)
jdbd:db2://[host]:[port]//[database] (network connection)
XML Extender Administrator LaunchPad
Create DAD file automatically
Creating a DAD file with XML Administrator Wizard
Creating a DAD file with XML Administrator Wizard
Creating a DAD file with XML Administrator Wizard
<?xml version="1.0"?><!DOCTYPE DAD SYSTEM "D:\AstroGrid\xml\db2Test\dad.dtd"><DAD> <dtdid>D:\AstroGrid\xml\db2Test\service.dtd</dtdid> <validation>YES</validation>
<Xcolumn> <table name="service"> <column name="maxNrows" type="varchar()" path="/serviceMetadataConcept/capabilitiesMetadataserviceRestriction/serviceMaxNrows" multi_occurrence="NO"/> <column name="restrictionSpatial" type="varchar()" path="/serviceMetadataConcept/capabilitiesMetadata/serviceRestriction/serviceRestrictionSpatial" multi_occurrence="NO"/> <column name="MSR" type="varchar()" path="/serviceMetadataConcept/capabilitiesMetadata/serviceRestriction/serviceRestrictionSpatial/serviceMSR" multi_occurrence="NO"/> . . . </table> </Xcolumn></DAD>
Creating a DAD file with XML Administrator Wizard
DB2 Enabling XML capabilities in DB2
<?xml?><!DOCTYPE..>
< element > . .</element >
. .<Xcollection> <table> <column> </table> . .<Xcollection>
XML Document DAD file
DB2
Next step is enable DB2 to work with XML documents:depends of the method (column or collection) how to do it.Could be command line or DB2 XML Extender Wizard.
XML Column
XML Collection
SQL mappinguses SQL select statement todefines DB2 tables and condition
RDB_node mappinguses X-Path based database node
Compose XMLDB2 to XML
Decompose XMLXML to DB2
Store procedure:
dxxGenXML()
dxxGenClob()
dxxRetrieveXML()
dxxRetrieveXMLClob()
dxxShredXML
dxxInsertXML
XML Extender methods
Next steps
Map Schema files
Use java and store procedure to decompose XML documents