next up previous contents index
Next: 2.2 Improving the simple Up: 2 Developing an nxqddb Previous: 2 Developing an nxqddb

2.1 Creating a simple addressbook

  The first step to creating your database is to determine where you want to store the information. Many users find it convenient to store all of their databases in one directory. For example, you could create your AddressBook database in your Databases subdirectory by executing the commands:



    1) $ cd ~
    2) $ mkdir Databases
    3) $ export QDDBDIRS=~/Databases
    4) $ cd ~/Databases
    5) $ qnewdb AddressBook
    6) $ vi AddressBook/Schema

  
Figure 2.1: Steps to create an AddressBook Qddb database





Lines 1 and 2 set up your Databases' directory. Line 3 establishes a search path so Qddb programs can find any relations in that directory. You can put this line in your .profile so that you will have a nice path set up each time you log in. We have shown the syntax for the bash shell; other shells establish environment variables by other syntax. Lines 4 and 5 create a new relation in a subdirectory called AddressBook. Line 6 invokes a text editor for you to create the Schema.


The Schema file contains a description of your database. In this Schema file, you enter all the field names that you want to store in Qddb.

For our sample database, we would enter the following in the Schema file:



Firstname verbosename ``First Name''
Lastname verbosename ``Last Name''
Street
City
State
Zipcode verbosename ``Zip Code''
Phonenumber verbosename ``Phone Number''

  
Figure 2.2: Simple Addressbook Schema






The optional verbosename keyword provides the label text that appears on the nxqddb window. The field names (e.g. Firstname, Lastname, Zipcode, Phonenumber) cannot have spaces; hence, we use the verbosename option to specify how the label should appear.

At this point, you've completed the steps to building your database application. To use your new database, just type the following at your command prompt:

    $ nxqddb AddressBook 

The nxqddb window(see figure 2.3)

  figure153
Figure 2.3: A simple address book - nxqddb interface

will appear to allow you to start entering information into your addressbook. Reference chapter 3 for details on how to use nxqddb windows.



Herrin Software Development, Inc.