Logical databases control which database structures can be accessed and how these structures can be used. When logical databases are declared in DASDL, the data sets, remaps, sets, subsets, and accesses that are to be included in each logical database are listed. Host language programs can invoke structures selectively from a logical database or can invoke the entire logical database. Programs can use only the structures contained in the logical database they invoke; thus, the database administrator can control which structures are accessed by controlling which logical database is used.
Logical databases can include XE structures.
Note: | If the database is audited, then any logical databases you declare must include the restart data set. |
A guard file can be assigned to each logical database. The guard file specifies who can invoke the logical database and how they can access it. Access can be restricted to specific users, specific programs, or specific users running specific programs. Each individual is assigned access rights. Some individuals can both access and alter the database, while others can only access it. When the guard file is created, the database administrator specifies which database operations each individual can perform. The guard file is checked when the database is opened and the Accessroutines enforces the access restrictions when the database is used.
The following diagrams illustrate the syntax for logical databases:
<logical database>
──<logical database name>─┬─ DATABASE ──┬─ ( <structure list> ) ───────► └─ DATA-BASE ─┘ ►─┬───────────────────────────┬────────────────────────────────────────┤ └─<logical database option>─┘
<structure list>
┌◄─────────────────────────── , ──────────────────────────┐ ──┴─┬──────────────────┬─┬─<data set name>─┬─┬────────────┬─┴──────────┤ └─ <identifier> = ─┘ ├─<remap name>────┘ └─<set part>─┤ └─/1\─┬─<database name>──────────┤ └─<global data remap name>─┘
<set part>
── ( ─┬─ ALL ───────────────────────────────────────────────┬─ ) ──────┤ ├─ NONE ──────────────────────────────────────────────┤ │ ┌◄────────────────── , ──────────────────┐ │ ├─ SET ──┬─┴─┬──────────────────┬─┬─<access name>─┬─┴─┘ └─ SETS ─┘ └─ <identifier> = ─┘ ├─<set name>────┤ └─<subset name>─┘
<logical database option>
── GUARDFILE ── = ──<file title>───────────────────────────────────────┤
The following table explains the elements of the syntax diagrams:
The following five examples illustrate the use of logical databases.
Example 1
The following DASDL description uses logical databases called LDB1 and LDB2. LDB1 contains data sets D and E, and sets S-D and S-E. LDB2 contains remaps R-D and R-E, and sets S-D and S-E. In addition, because the database is audited, both logical databases include the restart data set.
OPTIONS (AUDIT,REAPPLYCOMPLETED,INDEPENDENTTRANS); RDS RESTART DATASET (RDS-DATA ALPHA (30)); D DATA SET ( D1 ALPHA(5); D2 REAL; E DATA SET ( E1 NUMBER(4); E2 FIELD(8); ); S-E SET OF E KEY E1; R-E REMAPS E ( E1; ); ); R-D REMAPS D ( D1; R-E; S-E; ); S-D SET OF D KEY D1; LDB1 DATABASE (D, RDS); LDB2 DATABASE (R-D, RDS);
Example 2
The following DASDL description illustrates the use of logical databases:
% GLOBAL DATA G1 ALPHA(10); G2 NUMBER(S9,2); G3 REAL(12); R-G REMAPS EXDB ( G1 ALPHA(10) READONLY; G3; ); D1 DATA SET ( A REAL; B NUMBER(5); C ALPHA(5); ); S1A SET OF D1 KEY A; S1B SET OF D1 KEY B; D2 DATA SET ( X FIELD(8); Y ALPHA(5); Z FIELD(Z1;Z2;Z3;); E DATA SET ( K REAL; L IS IN E VERIFY ON K; M FIELD(14); ); S-E SET OF E KEY IS K; R-E REMAPS E ( K; M FIELD(14) HIDDEN; ); ); S2A SET OF D2 KEY X; S2B SET OF D2 KEY(X,Y,Z); R-D2 REMAPS D2 ( P = X; Q = Y ALPHA(5) READONLY; R = Z FIELD(R1=Z1; R2=Z2; R3=Z3;); R-E; S-E; ); LDB1 DATABASE(EXDB, D1(ALL), D2(SET S2=S2A)); LDB2 DATABASE(R-G, D=R-D2(SET S=S2B)); LDB3 DATABASE(D1, R-D2);
Example 3
The following ALGOL program illustrates the use of logical databases:
BEGIN DATABASE LDB1 OF EXDB; * GLOBAL DATA ITEMS: *02 STRING G1: ALPHA(10) *02 REAL G2: NUMBER(S9,2) *02 INTEGER G3: REAL(12) *01 D1: DATA SET (#3) * INVOKED SETS: * S1A (#4, AUTOMATIC), KEY = A * S1B (#5, AUTOMATIC), KEY = B * RECORD ITEMS: *02 REAL A *02 INTEGER B: NUMBER(5) *02 STRING C: ALPHA(5) *01 D2: DATA SET (#6) * INVOKED SETS: * S2 (#10, AUTOMATIC), KEY = X * RECORD ITEMS: *02 REAL X: FIELD(8) *02 STRING Y: ALPHA(5) *02 REAL Z: FIELD(3) *03 BOOLEAN Z1 *03 BOOLEAN Z2 *03 BOOLEAN Z3 *02 E: DATA SET (#7) * INVOKED SETS: * S-E (#8, AUTOMATIC), KEY = K * RECORD ITEMS: *03 REAL K *03 REAL M: FIELD(14) *03 L: LINK TO E * DESCRIPTION TIMESTAMP: 06/21/77 17: 39: 14 END. ============================================================ NUMBER OF ERRORS DETECTED = 0. NUMBER OF SEGMENTS = 1. TOTAL SEGMENT SIZE = 26 WORDS. PROGRAM SIZE = 3 CARDS, 7 SYNTACTIC ITEMS, 9 DISK SEGMENTS. PROGRAM FILE NAME: EXAMPLE/PROGRAM. COMPILATION TIME = 15.517 SECONDS ELAPSED; 0.905 SECONDS PROCESSING; ============================================================
Example 4
The following COBOL program illustrates the use of logical databases:
000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 DATA-BASE SECTION. 000600 DB LDB2 OF EXDB ALL. * LDB2 TIMESTAMP = 06/21/77 17: 39: 14 * 02 G1 PIC X(10) DISPLAY. * 02 G3 PIC 9(11) COMP. * 01 D STANDARD DATA SET(#12). * S SET(#11,AUTO) OF R-D2 KEYS ARE P,Q,R. * 02 P FIELD SIZE IS 08 BITS. * 02 Q PIC X(5) DISPLAY. * 02 R FIELD SIZE IS 03 BITS. * 03 R1 BOOLEAN. * 03 R2 BOOLEAN. * 03 R3 BOOLEAN. * 02 R-E STANDARD DATA SET(#9). * S-E SET(#8,AUTO) OF R-E KEY IS K. * 03 K COMP-4. 000700 PROCEDURE DIVISION. 000800 L. 000900 STOP RUN. COMPILE O.K. TOTAL CARD COUNT: 8 D[01] STACK SIZE: 0006(006) WORDS D[02] STACK SIZE: 0020(014) WORDS CORE ESTIMATE: 557 WORDS STACK ESTIMATE: 330 WORDS CODE FILE SIZE: 7 RECORDS PROGRAM SIZE: 2 CODE SEGMENTS, 15 TOTAL WORDS COMPILER COMPILED WITH FOLLOWING OPTIONS: BDMS, EXPERIMENTAL. COMPILE TIMES: ELAPSED CPU I-O 016.115 001.503 001.725