IBM DB2 Tools

DB2 is IBM's flagship relational database management system, and IBM DB2 tools in Stylus Studio® can significanly simplify and automate many tasks involving DB2 and XML. It's no surprise that Stylus Studio® and IBM DB2 should complement each other. Stylus Studio and IBM have been leading contributors to open-source projects such as those under the Apache Foundation, and both have pushed hard for open standards. Here are just some of the highlights of the many DB2 Tools in Stylus Studio® for working with relational and XML data:

  1. Writing, testing and debugging XQuery
  2. Publishing directly from the database

1. XQuery with IBM DB2 Server

Stylus Studio® fully supports DataDirect XQuery™ (an industry-leading XQuery processor), which you can use to query IBM DB2 with XQuery. The power of DataDirect XQuery™ comes to light when you realize that because both IBM DB2 and Stylus Studio® fully support the standard, Stylus Studio® can be used to edit and debug XQuery that will later be used in a production IBM DB2 environment.

Going further, while IBM DB2 alone allows you to merge XML and relational sources, Stylus Studio® allows you to merge in non-XML sources of data as well — including EDI and other legacy data formats, through integrated support for DataDirect XML Converters™.

Using the File Explorer, it's straight-forward to add a new reference to an IBM DB2 database. Right-click on Relational DB and pick New Server. Then fill in the dialog with the connection details, like this:

Once done, you drag and drop your connections onto the editing area to define a new collection. The setup for this demonstration uses an IBM DB2 server running on a machine named stylus (as far as this tutorial is concerned, either DB2 8 UDB or DB2 9 (Viper) behaves the same.)

XQuery against IBM DB2 (Click to enlarge)
(click to enlarge)

The way that XQuery against a relational database works is that the query is decomposed and reformulated in the specific SQL dialect of the underlying engine. Since DB2 supports XQuery natively, how is this an advantage? There are several:

  • Currently, DB2 supports the 03 November 2005 release of XQuery, while DataDirect XQuery™ is current at the 21 November 2006 draft.
  • On DB2, both SQL/XML and XQuery are compiled down to the same internal representation, and share the same execution engine. So while DataDirect XQuery™ insulates you from details about versions, in both cases the underlying engine is identical. In fact, to quote from an IBM DeveloperWorks article, "No matter what combination of SQL and XQuery you choose in one statement, DB2 uses a single hybrid compiler to produce and optimize a single execution plan for the entire query -- without incurring a performance penalty for query execution."

DataDirect works hand-in-hand with database vendors including IBM to understand the details of query optimization, and the drivers are continually update to take advantage of new server-side changes and new client-side optimization strategies.

What you write is standard XQuery, but what IBM DB2 receives is the IBM DB2 dialect of SQL. This means what you put together never has to stoop to vendor-specific slang, but can remain pure — and more importantly, portable (IBM is proud of its pureXML concepts, and we whole-heartedly support those same ideals in our tools.)

This also helps in planning for the future. When it comes time to reevaluate your database decision, whether the choice is to upgrade to DB2 10 (or whatever it may be called) or to switch databases, you are shielded from underlying changes in syntax. Your application can remain untouched, and the drivers we supply will mask any differences in the underlying database engine implementation.

Since the XQuery is initiated from the client, other actions can be taken whose realm is outside that of the database. For example:

Publishing. Once you've connected to the database, it is a simple matter to use this database for XML reporting or publishing, as you'll see shortly.

Pipelines. XQuery doesn't have to stand alone; they can also be embedded in XML Pipelines for multi-stage transformation and output generation.

2. Publishing from IBM DB2

Just dragging the IBM DB2 JDBC Entry from the File Explorer to the XML Report data sources pane makes it available for use in publishing from XML.

The XML Report module lets you draw your output on the screen, and then builds XSLT 1.0, XSLT 2.0 or XQuery 1.0 that will in turn output HTML+CSS or XSL-FO. You can then use that generated program code in your own applications, or as part of an XML Pipeline to accomplish elaborate operations.

There's much more to XML publishing, as you can see by following this link.

By no means is this the end, but we've just taken you on a tour of some of the highlights as to how IBM DB2 can be used more effectively with Stylus Studio® for both developing XQuery and also manipulating the XML and relational data stored within it. We hope you'll take the opportunity to download and evaluate our award winning DB2 tools Stylus Studio® today!

Free Stylus Studio XML Training:
W3C Member