Overview
Page 3 of 3

The JBMSTours Scenario

Throughout this tutorial, we will be asking you to work with a Java application and database automatically installed with Cloudscape. The sample database is called toursDB; the sample application consists of a package of Java classes called JBMSTours. You will learn more about the specifics of this application in The Application: The JBMSTours Package.

To make the most sense of the example, imagine the following scenario:

The Company

Our fictional company, JBMSTours, is a travel company specializing in do-it-yourself customized tours. The company distributes software that allows customers to book complete tours to two cities of their choice, including hotel stays as well as flights.

JBMSTours has chosen to write the software in Java, because Java frees the firm from a specific operating system or type of hardware; the software can run on any computer with a JVM. Since the application is data-centric (it must find information about cities, and about available flights, and hotels), it needs to access a database. The company doesn't want customers to have to be connected to a central database server or wait for slow connections over the Internet; instead, JBMSTours wants each copy of the application to have its own copy of the database and the necessary database management software.

JBMSTours has chosen Cloudscape as its database management software, for the following reasons:

  • Cloudscape is written entirely in Java and can be "embedded" in the distributed software as simply another set of Java class files, invisible to the user.
  • Cloudscape does not require the special installation or configuration of other personal database software, making the entire package--the JBMSTours software and the underlying database software--easy to use.
  • Cloudscape's object-relational technology and Java extensions mean that where appropriate, JBMSTours can store data exactly as the application uses it--as Java objects. It doesn't have to "translate" business models into other kinds of data.
  • Cloudscape synchronization means that clients can keep databases up to date and upload any changes made locally. Synchronization is done in the background without any input needed from the user. (The current version of this tutorial does not address synchronization.)

The Application: The JBMSTours Package

The fictional company's fictional application and database are included with your installation. The application consists of a set of class files, with a few main or entry classes (which contain main() methods). Javadoc for the application is also included; we encourage you to examine the javadoc as you do this tutorial. Javadoc is automatically generated HTML documentation about a Java class or package.

You may also look at the Java source files, which are also provided.

  • the javadoc

    is located in the demo/programs/tours/javadoc directory in the cloudscape base directory

  • the Java source files

    are located in the demo/programs/tours/JBMSTours directory in the cloudscape base directory

  • the compiled classes

    are located in the demo/programs/tours/JBMSTours directory in the cloudscape base directory

Application Overview

Taking advantage of the object paradigm, the JBMSTours application builds a Tour object for the customer using it to create and book a tour. For the sake of simplicity, a Tour object in the example application is a two-city tour that includes a flight from the user's home city to the first city, a flight to the second city, and a return flight back home. It also includes a hotel stay in each of the two cities visited.

The classical reason for using a DBMS is that it provides the following:

  • querying

    It allows you to query complex and large data stores for specific information.

  • persistence

    It allows you to make your data persistent by storing it.

The sample application uses Cloudscape for both purposes. It queries the databases to get information about cities, flights, and hotels, and it stores information in the database to make it persistent.

The Application Queries the Data

When generating a Tour object, the application queries the database for information about countries, cities, hotels, flights, and airlines.

JBMSTours stores a repository of core data in the toursDB database:

  • countries

    Stored as SQL-92 data types in the Countries table. The application only reads this data; it does not change or add to this data.

  • cities

    Stored as Java objects in the Cities table. The application only reads this data; it does not change or add to this data.

  • hotels

    Although these are Java objects in the application, they are "translated" into flat data in the Hotels table. (Translating an object into flat data is sometimes called object-relational mapping.) Information about a hotel's availability on specific dates is stored as SQL-92 data types in the HotelAvailability table. The application only reads the Hotels table, but as it books tours it writes to the HotelAvailability table.

  • flights

    Stored as SQL-92 data types in the Flights table. Information about a flight's availability on specific dates is stored as SQL-92 data types in the FlightAvailability table. The application only reads the Flights table, but as it books tours it writes to the FlightAvailability table.

  • airlines

    Stored as SQL-92 data types in the Airlines table. The application only reads the Airlines table.

The application queries these tables to construct a Tour object.

A Tour object itself is made up of other Java objects--CustomerFlights, HotelStays, dates, and some other data.

The Application Stores Tour Data

After a user constructs a tour of his or her choice, the application writes some information to the database.

  • tours

    Once the entire tour is booked, the application stores the Tour object itself in a table called CustomizedTours.

  • hotel bookings

    The application represents customer- and date-specific information about a hotel stay as a HotelStay object, which is stored only as part of a Tour. As it books a tour, the application stores some information about a HotelStay in the HotelBookings table.

  • flight bookings

    The application represents customer- and date-specific information about a flight as a CustomerFlight object, which is stored only as part of a Tour. As it books a tour, the application stores some information about a CustomerFlight in the FlightBookings table.

  • groups

    The application represents the group of people booking a tour as a Group object. The application translates Groups into flat data and store them in the table called Groups.

  • people

    The application represents the individual people in a group as Person objects (or as an Adult or Child objects, which are subclasses of Person). The application stores these objects in the People table.

    People are mapped to Groups in the Groups_People table.

The Application May Use Synchronization

In a Cloudscape synchronization system, information stored in tables by an application would be available at the company office and subsequently to the airlines and hotels with which JBMSTours does business. Depending on how the back office processes the data, replicating data allows the application to actually book tours. The application does not yet take advantage of synchronization.

One "Temporary" Table: FlightObjects

The JBMSTours application treats flights as Java objects. However, it stores basic flight information as SQL-92 data types, because of the large quantity of flight data. In the current release, it is faster to search tables holding SQL-92 data types because you can index the data. An index is a database object that allows Cloudscape to find specific data more quickly. You cannot currently index Java data types or Java methods.

Before it builds a tour, the application searches the large Flights tables and generates several Flight objects based on the airport codes of cities the customer will visit. The appropriate airport columns are indexed in the table.

However, when actually constructing a tour, the application wants to select the appropriate flight (or a set of flights that make up a transfer flight) based on more complex criteria. The application represents a flight as a Flight, OneStopFlight, or TransferFlight object. It stores them in a table called FlightObjects. When the customer actually chooses a flight, the application can search through the small FlightObjects table and use the Flight object's rich set of methods to choose the best flight for the customer.

For example, for a customer visiting Paris, the application cleans out the FlightObjects table. Then it searches for flights from the airport of the customer's home city and to the airport in Paris and constructs a set of Flight objects. These various flight objects might be direct flights, one-stop flights, or transfer flights.

When it comes time to build the tour, the application can search the FlightObjects table based on methods such as getTotalDuration or getRate to choose the best flight for the customer.

What You Will Be Doing with JBMSTours

In the lessons that follow, you will:

Or Look on Your Own . . .

You can bypass the lessons in this tutorial. If you just want to build the sample database and run the end-user applications, run them in this order:

  • JBMSTours.CreateToursDB
  • JBMSTours.CreateScript
  • JBMSTours.BuildATour
  • JBMSTours.GenerateReport
  • JBMSTours.ArchiveData
  • JBMSTours.RunTime
  • JBMSTours.AdminHelper

In a Client/Server Environment

In this tutorial, you will be working in an embedded environment. That is, you will work with an application that starts up an instance of Cloudscape. However, all the JBMSTours programs can be run as client applications with either RmiJdbc Server or Cloudconnector (purchased separately).

To run these applications as client applications to a running server, provide two command-line arguments when you run them:

  • hostname

    the hostname where your server framework is running

  • port number

    the port number on which your server framework is listening

If you are using the RmiJdbc framework, add the single character r.

For example:

java JBMSTours.CreateToursDB jeeves 7001
java JBMSTours.BuildATour bertie 1099 r

This tutorial does not teach you how to start a server. The Cloudscape Server and Administration Guide can help you get started with that task.