ISQL and Tools

2.2RELATIONAL MODEL AND INDEXING TUTORIAL

iSQL_Tutorial2.sql

This intermediate tutorial will advance the concepts introduced in the first tutorial by expanding the number of tables and building a relational model. This tutorial will walk you through defining an index for each table, demonstrating the power of indexes in a rela- tional model using a few simple API calls.

This tutorial operates on the assumption that the database named 'myDatabase', already exists. Please refer to Section 3.6 “Introduction to the c-treeSQL ISQL Utility” in c-tree Plus Quick Start and Product Overview Guide for details on how to set up the environment for the tutorial.

This example, like all others in this set of documentation, will take the creation and use of a database and fit it into a simple four step flow of initialization, definition, management, and completion. (Init, define, manage, and you're done!)

Now let's break into the four areas.

2.2.1Init

The initialize step is as simple as launching the iSQL tool. The syntax for this is as follows:

isql [-u user_name] [-a password] [connect_string]

At the command line prompt type:

isql -u ADMIN -a ADMIN myDatabase

iSQL responds with the following prompt:

ISQL>

At this point, any valid SQL statement terminated with a semi-colon may be submitted.

2.2.2Define

In this case define consists of the CREATE TABLE statement. This is done in a single iSQL statement in which specific fields are defined. Upon successful creation of the table, the changes made to the database by this transaction are made permanent by executing the COMMIT WORK statement.

Relational Database

This process of defining tables and indices is in actuality creating

a relational database. For the sake of simplicity, we will not be enforcing constraints use in this tutorial. In this example there are 4 tables being defined as depicted in the drawing below. The fields that make up the index are shown in bold italics.

2-4

FairCom Corporation

Page 14
Image 14
HP c-tree-SQL ISQL and Tools manual Relational Model and Indexing Tutorial, ISQLTutorial2.sql