6 Example Operations

Database Definition and Creation

Once the database has been designed, the database definition language (DBDL) is used to define (describe) the database. An editing program, such as vi, is used to create a data file with the definitions. The following listing defines the Sales Analysis Database (SAD) described in the previous section, page 142 :


BEGIN DATABASE SAD;

PASSWORDS:
         3 SECRETARY;
        10 SALESMAN;
        15 MANAGER;

ITEMS:
        ADDRESS,        2 X30;
        CITY,           X16;
        COUNTRY,        X12;
        DATE,           I;
        NAME,           X30;
        OPTION-DESC,    X10;
        OPTION-PRICE,   L;
        OPTION-TYPE,    I;
        ORDER-DATE,     I;
        ORDER-NO,       X10;
        PRICE,          L;
        PRODUCT-NO,     I;
        PROD-DESC,      X30;
        REGION,         X6;
        REGION-DESC,    X30;
        REGION-TYPE,    I;
        SALESPERSON,    X4;
        SHIP-DATE,      I;
        STATE,          X6;
        ZIP-CODE,       X8;
        DUMMY,          S;

SETS:

N:      DATE, AUTOMATIC (3/10,15);
E:      DATE (2);

N:      ORDER, A (3/10,15);
E:      ORDER-NO (2);
N:      PRODUCT, MANUAL (3,10/15);
E:      PRODUCT-NO (1),
        PROD-DESC;

N:      LOCATION, M (3,10/15);
E:      REGION (1),
        REGION-DESC,
        REGION-TYPE;

N:      OPTION, DETAIL (3/10,15);
E:      ORDER-NO (ORDER),
        OPTION-DESC,
        OPTION-PRICE,
        OPTION-TYPE;

N:      CUSTOMER, D (3/10,15);
E:      ORDER-NO (ORDER),
        NAME,
        ADDRESS,
        CITY,
        STATE,
        COUNTRY,
        ZIP-CODE,
        ORDER-DATE (DATE),
        SHIP-DATE (DATE),
        REGION (LOCATION),
        PRODUCT-NO (PRODUCT),
        PRICE,
        SALESPERSON,
        DUMMY;

END.
The next step is to create the database root file. This is done by using the schema program, described in page 41 . For example, if the database definition is saved in the data file SAD.txt, start the schema program from the HP-UX prompt as follows:


schema SAD.txt
Once the schema program has created the root file, the data set files are created using the dbcreate command or the DBCREATE statement (discussed in page 105 ). An example of the dbcreate command follows:


dbcreate SAD

Eloquence Database Manual - 19 DEC 2002