|
The paper, “XTABLES: Bridging relational technology and XML” described the design and implementation of the XTABLES middleware system, which was intended to act as a bridge between legacy relational database systems and the emerging number of XML (Extensible Markup Language)-based applications. XTABLES uses relational databases for storing and querying XML documents.
An example carried throughout that paper concerned a simple purchase order database. Views of this database, both default and user-defined, could be queried by the use of XQUERY expressions. The sample data shown in Figure 1 (Figure 2 of the original paper) can be generated by the Structured Query Language (SQL) commands shown in this technical note in Figure 2.
Figure 1
Figure 2
Figure 1 (Figure 2 in the original paper) shows the default XML view for the purchase order database. This view can be generated by the following query:
namespace xp = "http://www.ibm.com/2001/12/xquery-functions"
<db>
{xp:table("EPURCHASE","ORDER")}
{xp:table("EPURCHASE","ITEM")}
{xp:table("EPURCHASE","PAYMENT")}
</db>;
The user-defined XML view (a “create view” called “orders”) shown here in an updated Figure 3 (Figure 4 in the original paper) transforms the default view into an XML format as desired by the user.
Figure 3
Queries can be issued against this user-defined view. The following two options for queries produce the same results, extracting a list of “item” elements from this view for a customer whose name begins with “Smith.” In the original paper the “like” operator, undefined in XQUERY, was used.
Query using the XQUERY “starts-with” function:
for $order in view("orders")
let $items := $order/items
where starts-with(data($order/customer), "Smith") eq 'true'
return $items;
Query using the XQUERY “contains” function:
for $order in view("orders")
let $items := $order/items
where contains(data($order/customer), "Smith")
return $items;
These queries can be parsed and converted to XQGM (XML Query Graph Model), then translated to SQL. For the “starts-with” query, the SQL produced is shown in Figure 4, including the “with” clause for common subexpressions. Note that the “starts-with” function is translated into a user-defined function xperanto.“starts-with”, which is implemented by XTABLES.
Figure 4
For the “contains” query, the SQL produced (including the “with” clause for the common subexpressions) is shown in Figure 5. Note that the “contains” function is translated into the SQL “locate” function.
Figure 5
General references
J. E. Funderburk, G. Kiernan, J. Shanmugasundaram, E. Shekita, and C. Wei, "XTABLES: Bridging relational technology and XML," IBM Systems Journal 41, No. 4, 616–641 (2002).
Accepted
for publication December 12, 2002; Internet publication July 17, 2003 |