IBM's eServer
Business Solution Test (BST) team designs, implements, evaluates, and deploys
customer-like scenarios. The team consists of iSeries developers in the
Rochester laboratory who design scenarios that demonstrate how iSeries
technology can be used to build e-business solutions. Although the team is
restricted to a test laboratory environment, great effort is made to reflect
reality.
Recently, the BST team created an application called Travel
Flights Cruises (TFC), which simulates several fictitious companies in a B2B
relationship, including a cruise line, a cruise Web site, a travel agency, and a
bank. The travel agency and bank used DB2 XML Extender for iSeries to compose,
decompose, and archive Extensible Markup Language (XML) documents. The following
provides an overview of the DB2 XML Extender for iSeries product and examples of
how TFC utilized it.
DB2 XML Extender Overview
XML is extensible in that the language is a
metalanguage that allows you to create your own language, depending on the needs
of your enterprise. You use XML to capture not only the data for your particular
application, but also the data structure. Although it is not the only data
interchange format, XML has emerged as the accepted standard. By adhering to
this standard, applications can share data without first transforming it using
proprietary formats.
DB2 XML Extender helps you integrate the power of
IBM's DB2 Universal Database for iSeries (DB2 UDB) with the flexibility of XML.
It provides the ability to generate XML documents from existing data, insert
rows into tables from XML documents, and store and access XML documents. XML
Extender provides new data types, functions, and stored procedures to manage
your XML data in DB2 relational databases.
To view IBM's document on DB2
UDB XML Extender Administration and Programming, click
here.
XML Document
Examples
XML documents were used by the cruise line and the
travel agency to handle the processing of buying and booking cruises. These XML
documents contain the itinerary or passenger information and allow integration
between the cruise line and the travel agency. The following XML documents were
used:
- Itinerary--The cruise line provides the travel agency with detailed itinerary information about cruises they have purchased. The travel agency decomposes this XML document into DB2 database tables. The data within these tables is used by other applications to book cruises for specific customers.
- Passenger--The travel agency provides the cruise line with detailed passenger information for the cruises they have booked for specific customers. This XML document is composed based on the information in DB2 database tables.
Decomposition Example (Itinerary)
Let's take a look at the XML Extender pieces of the
itinerary application that allows the travel agency to receive the itinerary XML
document from the cruise line. The itinerary XML document contains all of the
itinerary information for the cruises that were ordered by the travel agency,
based on an order number. The itinerary XML document is decomposed by the travel
agency into several DB2 database tables. The travel agency uses an XML
collection for storage of the XML data and a custom-designed document type
definition (DTD) for the itinerary XML document since there were no suitable
industry standard DTDs available at the time the application was
developed.
Database Details
The XML
document is decomposed into five DB2 tables:
- cruise_info
- rooms
- port_of_calls_temp
- activities_temp
- day_temp
The cruise_info table contains cruise information
that is received from the cruise line, as shown in the following table:
Key
|
Field Name
|
Alias Name
|
Data Type
|
Length
|
VarLen Alloc
|
Digits, DecPos
|
Description
|
P
|
BOOKING#
|
BOOKING_NBR
|
VARCHAR
|
20
|
10
|
|
Booking number
|
|
CRUISECO
|
CRUISE_CO
|
VARCHAR
|
40
|
20
|
|
Cruise line name
|
|
ORDER#
|
ORDER_NBR
|
VARCHAR
|
20
|
10
|
|
Order number
|
|
PRODID
|
PRODUCT_ID
|
VARCHAR
|
20
|
10
|
|
Product ID
|
|
CRUISEID
|
CRUISE_ID
|
VARCHAR
|
20
|
10
|
|
Cruise ID
|
|
CRUISEDESC
|
CRUISE_DESC
|
VARCHAR
|
30
|
10
|
|
Cruise description (7 Day...)
|
|
ROOMDESC
|
ROOM_DESC
|
VARCHAR
|
30
|
10
|
|
Room description (std ,ocean, ...)
|
|
COSTSING
|
COST_SINGLE
|
PACKED
|
|
|
7,2
|
Cost to the agency for single occupancy
|
|
COSTDOUB
|
COST_DOUBLE
|
PACKED
|
|
|
7,2
|
Cost to the agency for double occupancy
|
|
COSTADD
|
COST_ADDITIONAL
|
PACKED
|
|
|
2,2
|
Cost for each additional person over two
|
|
CUSTCOST
|
CUST_COST
|
PACKED
|
|
|
2,2
|
Cost to the customer with commission added (percentage)
|
|
DUR
|
DURATION
|
INT
|
|
|
|
Duration of cruise
|
|
DEPTDATE
|
DEPARTURE_DATE
|
DATE
|
|
|
|
Departure date of cruise
|
The rooms table shown below contains the room numbers that were bought
from the cruise line. It is used to track the rooms that are sold to the travel
agency customers.
Key
|
Field Name
|
Alias Name
|
Data Type
|
Length
|
VarLen Alloc
|
Digits, DecPos
|
Description
|
P,F
|
BOOKING#
|
BOOKING_NBR
|
VARCHAR
|
20
|
10
|
|
Booking number
|
P
|
ROOMNBR
|
ROOM_NBR
|
VARCHAR
|
10
|
6
|
|
Room number
|
|
STATUS
|
BOOKED_STATUS
|
CHAR
|
1
|
|
Y
|
Room status (O=open, B=booked, D=cruise has sailed)
|
|
PDCRUISE
|
PD_CRUISE_LINE
|
CHAR
|
1
|
|
Y
|
Paid cruise line status (U=unpaid, P=paid)
|
Within the Document Access Definition (DAD) file, no option exists to
specify that only unique records should be inserted into the database tables.
Within the XML document, for each cruise, there is a corresponding set of ports
of call and activities listed. When the XML document is decomposed, the
appropriate data is inserted into the port_of_calls and activities tables. The
travel agency wanted to ensure that only one set of ports of call and activities
is inserted in those tables for each cruise to avoid having the tables populated
with duplicate records.
To accomplish this, two temporary tables
(port_of_calls_temp and activities_temp were used for the decomposition. Two
INSERT triggers (Enter_Port_Of_Calls and Enter_Activities) were added to those
tables to insert the new row into the port_of_calls and activities tables if
they did not already exist. Two more triggers (Remove_Port_Of_Calls and
Remove_Activities) were used to delete the data from the temporary
files.
The port_of_calls_temp table is a temporary table used for
decomposing the XML document. The actual data is stored in the port_of_calls
table. The port_of_calls table contains the same type of information, as shown
in the following table:
Key
|
Field Name
|
Alias Name
|
Data Type
|
Length
|
VarLen Alloc
|
Digits, DecPos
|
Description
|
|
CRUISECO
|
CRUISE_CO
|
VARCHAR
|
40
|
20
|
|
Name of cruise line
|
|
CRUISEID
|
CRUISE_ID
|
VARCHAR
|
20
|
10
|
|
Cruise ID
|
|
DAYNBR
|
DAY_NUMBER
|
INT
|
|
|
|
Day number (e.g., 1, 2, 3, ...)
|
|
PORT
|
PORT_OF_CALL
|
VARCHAR
|
30
|
10
|
|
Name of port
|
|
ARRTIME
|
ARRIVE_TIME
|
TIME
|
|
|
Y
|
Time of arrival at port
|
|
DEPTTIME
|
DEPART_TIME
|
TIME
|
|
|
Y
|
Time of departure from port
|
The activities_temp table is a temporary table used for decomposing the
XML document. The actual data is stored in the activities table. The activities
table contains the same type of information:
Key
|
Field Name
|
Alias Name
|
Data type
|
Length
|
VarLen Alloc
|
Digits, DecPos
|
Description
|
|
CRUISECO
|
CRUISE_CO
|
VARCHAR
|
40
|
20
|
|
Name of cruise line
|
|
CRUISEID
|
CRUISE_ID
|
VARCHAR
|
20
|
10
|
|
Cruise ID
|
|
DAYNBR
|
DAY_NUMBER
|
INT
|
|
|
|
Day number (e.g., 1, 2, 3, ...)
|
|
ACTTIME
|
ACTIVITY_TIME
|
TIME
|
|
|
Y
|
Time of activity
|
|
DESC
|
DESCRIPTION
|
VARCHAR
|
100
|
20
|
|
Description of activity
|
The day_temp table contains the day number for the activities and ports
of call, as shown in the following table:
Key
|
Field Name
|
Alias Name
|
Data type
|
Length
|
VarLen Alloc
|
Digits, DecPos
|
Description
|
|
DAYNBR
|
DAY_NUMBER
|
INT
|
|
|
|
Day number
|
DTD
The DTD document used within this
example is shown in Figure 1.
|
Figure 1: This is the sample XML code for the
DTD.
XML Document
An example of what
the XML document looks like is shown in Figure 2:
|
Figure 2: Here's the sample XML document.
DTD
Mapping Scheme
The following table illustrates how the structure
of the XML document relates to the DB2 tables that are used for the
decomposition. This is helpful in the creation of the DAD file because it shows
how the two structures compare.
Element
|
Attribute
|
Value
|
Table(s)
|
Column
|
Itinerary Information
|
|
|
|
|
CruiseProduct
|
|
|
|
|
OrderNumber
|
|
123463
|
cruise_info
|
order_nbr
|
Company
|
|
Cruise Company
|
cruise_info
activities_temp port_of_calls_temp |
cruise_co
cruise_co cruise_co |
ProductID
|
|
9899
|
cruise_info
|
product_id
|
BookingNumber
|
|
105
|
cruise_info
rooms |
booking_nbr
booking_nbr |
CruiseID
|
|
00011
|
cruise_info
activities_temp port_of_calls_temp |
cruise_id
cruise_id cruise_id |
CruiseDescription
|
|
5-day Caribbean
|
cruise_info
|
cruise_description
|
RoomDescription
|
|
Oceanview
|
cruise_info
|
room_desc
|
DepartureDate
|
|
10/12/2000
|
cruise_info
|
departure_date
|
ReturnDate
|
|
10/15/2000
|
|
|
Duration
|
|
4
|
cruise_info
|
duration
|
SinglePrice
|
|
399
|
cruise_info
|
cost_single
|
DoublePrice
|
|
199
|
cruise_info
|
cost_double
|
ExtraOccupantCost
|
|
199
|
cruise_info
|
cost_additional
|
Schedule
|
|
|
|
|
Day
|
dayNumber
|
1
|
day_temp
activities_temp port_of_calls_temp |
day_number
day_number day_number |
Port
|
location
|
Miami, Florida
|
port_of_calls_temp
|
port_of_call
|
|
arrive
|
|
port_of_calls_temp
|
arrive_time
|
|
depart
|
5:00 PM
|
port_of_calls_temp
|
depart_time
|
Activity
|
|
Fireworks off starboard side of ship
|
activities_temp
|
description
|
|
time
|
11:00 PM
|
activities_temp
|
activity_time
|
NumberOfRooms
|
|
5
|
|
|
Rooms
|
|
|
|
|
Room
|
roomNumber
|
111
|
rooms
|
room_nbr
|
Room
|
roomNumber
|
...
|
rooms
|
room_nbr
|
Room
|
roomNumber
|
115
|
rooms
|
room_nbr
|
DAD
Figure 4 shows the DAD document used
within this example. This DAD
file for an XML collection uses RDB_node
mapping.
|
LATEST COMMENTS
MC Press Online