Skip to main content

Develop SQL-XQuery Web service translator for DB2 9 with IBM Rational RequisitePro and Rational ClearCase

Automate translating service for the hybrid database system

Judith Myerson (jmyerson@bellatlantic.net), Systems architect and engineer
Judith M. Myerson is a systems architect and engineer. Her areas of interest include middeware technologies, enterprise-wide systems, database technologies, application development, network management, distributed systems, component-based technologies, and project management. You can contact her at jmyerson@bellatlantic.net.

Summary:  Want to translate SQL into XQuery and vice versa when you prepare to query the hybrid database system? Learn how to develop Web services to map from SQL to XQuery, compile XQuery to SQL, and translate portions of the SQL queries as embedded XQuery statements. You'll see examples of how you can use IBM® Rational® Requisite Pro and IBM Rational ClearCase as part of the collaborative efforts in the translation process.

Date:  20 Nov 2006
Level:  Intermediate
Activity:  1600 views

Introduction

Gone are the days of storing XML data as a Character Large Object (CLOB) or shredding to relational tables. The problem was that after you decomposed an XML document, stored it and then put it back together, you did not end up with what you started with. Gone are the days of the inability of SQL statements to search and sort huge amount of data like the XQuery statements do. It took much longer to process queries (shredded and non-shredded), and to add fields to schema with a relational data server than those with the hybrid data server.

To reduce storage time and requirements, IBM has come up with DB2® 9, a hybrid database system that can store both structured and unstructured data in their respective formats. The integrity of XML documents is preserved, and they do not need to be shredded or decomposed. The user can switch from SQL to XQuery when the data is huge.

Hybrid data types

You can access both relational and XML data but you can also mix these within a single request more quickly than you would access either data type even as the data volumes grow. More and more data are being retained for a longer period of time as part of regulatory compliance.

By combining these data types, IBM has made it possible, with its hybrid XML/relational storage mechanisms, to reduce substantially data storage requirements and the time to process XQuery and SQL queries. You can create and manage much larger database systems by putting multiple table spaces under a single table, divide data across multiple machines and organize data by dimension all by partitioning mechanisms.

To enhance security, DB2 9 provides an innovative label-based access control (LBAC) that assigns user permissions to each row, or a table consisting of multiple table spaces across different machines. It allows you manage data load or backup by partition. However DB2 9 has limitations that we can overcome with Web services. We need to take a look at each limitation and possible solutions for it.

Web service data analysis

The user has no way of knowing if he should use SQL or XQuery to form queries. He does not know the amount of relevant data he wants to query. He needs to find out if the data volume is huge.

I suggest Web Service Data Analysis to advise the user what statement format to use based on how the system analyzes the data across the machines, organized by dimension, or in multiple table spaces under a table. If the analysis shows that the data or a portion of the data to be queried is huge, it would send a message suggesting XQuery statements as a preferred method.

Web service Translator

What if the user is more fluent with SQL statements and has little or no working knowledge of the XQuery statements? What if the user speaks XQuery and is not comfortable with SQL statements? What if the user is more fluent with SQL for a different database management system that he has migrated to DB2 9?

This decision maker may not be able to afford to wait to learn the XQuery, as he may be required to make instant decisions. DB2 9 is unable to translate from SQL queries to those of XQuery and vice versa, and check if the translated SQL or XQuery queries have been optimized to consume least resources.

SQL queries not well formed have been known to slow down performance of a relational database. This is also true for improperly formed XQuery statements embedded within the well-formed SQL statements. Even with a hybrid data server, improperly formed queries will not perform as well.

Child checkers

Before we translate either SQL or XQuery statements into another, or embed the XQuery statements into the SQL queries, we need to check the syntax of each. It is obvious SQL and XQuery have differences in syntactic and scoping conventions.

Compared to a typical relational system catalog, XML schema information is often more complex and subject to change. XQuery may operate over multiple documents forming to different schemas or to multiple versions of a schema. Some documents may not have a schema.

Hence, we need to create three child Web services for its parent Web service Translator. They are:

  • Web service SQL checker
  • Web service XQuery checker
  • Web service embedded XQuery checker

Child processors

Once the checker has verified that SQL or XQuery statements are well formed on the hybrid database server, the next step is to send the results as input into one of the following child Web services:

  • Web service SQL-XQuery Translator
  • Web service XQuery-SQL Compiler
  • Web service Embedded XQuery Compiler

The SQL-XQuery Translator maps SQL to XQuery. If the output gives a list of translation issues, they must be resolved. The SQL and XQuery have differences in syntactic and scoping conventions.

While the XQuery-SQL compiler will process the translation faster, it is more likely to produce portions of the SQL code that can give the same outputs. The compiler should have a mechanism to detect portions of the SQL code that appears to give redundant results. This means downsizing of the SQL code will be necessary. There should be a mechanism to suggest what portions of the SQL code can perform the best in consuming scarce resources without resulting in system overloads even during the abrupt changes in network traffic.

The Embedded XQuery Compiler is designed to replace certain portions of the translated SQL statements into the XQuery counterparts. It is particularly useful and more feasible in handling huge data that the SQL cannot even on a hybrid database system.

For all three child Web services, feedback will be necessary until all translation issues have been resolved in meeting user requirements. Change management must be in place to increase productivity.

Web service Performance Analyzer

The user has no way of determining if the differences between the SQL and XQuery statements appears to be marginal in consuming like resources. DB2 9 does not have the capability to conduct various testing types to determine which query type is optimal: SQL or XQuery. It is unable to provide information on the impact of disk fragmentation on the execution of the statements by partition and across the machines.

After the translation issues have been resolved, the final step is create Web service Performance Analyzer that the developer could use to compare the performance of SQL and XQuery codes in a non-production environment before they are actually executed on huge data. The query performance with separated data must prevent scans of irrelevant data.

Here is the partial list of performance testing types. When the developer executes a testing type, he may find problems that other types could not reveal. Of these tests, volume and stress testing should be conducted to ensure that the queries in a production environment will not result in system overloads.


Table 1. Performance testing types
TypeQuestions
Functional testingIs the query working properly? Are the results the end users expected? What about business executives? Which query type (SQL or XQuery) show better results?
Volume testingAre the queries working properly under heavy production volumes of data? How much volume each query type can handle?
Stress testingWill low resources create problems? Which query type shows it can handle resource stress better than the others?
Backup and recovery testingAre the backup and recovery processes working properly? How fast can each query type recover from expected and unexpected downtimes?
Configuration testingAre the processes of each query type working properly with the updated version of the operating systems and associated Web service applications? Which query type shows better configuration?
Documentation testingIs online documentation sufficient to assist system administrators and users understand how to use Web services to check the amount of relevant data, check the syntactic and scoping conventions of the queries, translate from one query type to another and resolve translation issues?
Load testingCan the system handle sudden changes in traffic?
Information assurance testingCan the Web services meet the criteria of confidentiality, integrity and availability?
Security access controlCan authorized users access the LBAC designated rows or tables as specified?
Back-end interface testingWill the interface of queries with back-end applications and databases work properly?

Conclusion

Developing Web services to translate SQL into XQuery and vice versa requires collaborative efforts from a team of developers, business analysts, system administrators, and potential users. It requires planning ahead to create, test, and deploy Web services to analyze data, to automate translation and test performance of the results under varying conditions. More than one performance test should be conducted, as one testing type may reveal problems that some other types did not. Of these tests, volume and stress testing should be conducted to ensure that the queries in a production environment will not result in system overloads.

You will find that resolving the issues makes your job of developing Web services to analyze data, to translate queries and to perform tests much easier. You can use IBM Rational RequisitePro to manage a hierarchy of requirements. You can use IBM Rational ClearCase to increase productivity by reducing build/release cycle times through more efficient change management.


Resources

Learn

Get products and technologies

  • Get installation details on IBM WebSphere Application Server.

  • Access Web services knowledge, tools, and skills with Speed-start Web services, which offers the latest Java-based software development tools and middleware from IBM (trial editions), plus online tutorials and articles, and an online technical forum.

  • IBM trial products for download: Build your next development project with IBM trial software, available for download directly from developerWorks.

Discuss

About the author

Judith M. Myerson is a systems architect and engineer. Her areas of interest include middeware technologies, enterprise-wide systems, database technologies, application development, network management, distributed systems, component-based technologies, and project management. You can contact her at jmyerson@bellatlantic.net.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services, Information Management
ArticleID=175534
ArticleTitle=Develop SQL-XQuery Web service translator for DB2 9 with IBM Rational RequisitePro and Rational ClearCase
publish-date=11202006
author1-email=jmyerson@bellatlantic.net
author1-email-cc=flanders@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers