Information Management System IMS
Databases
What is a database?
A way of organizing data
Why database ? Increase data independence Increase data security Reduce data redundancy Maintain data integrity
TYPES OF DATABASES
Hierarchical databases Network databases Relational databases
NETWORK MODEL
COMPANY
CLUB
BUILDING
VEHICLE
PERSON
RELATIONAL MODEL
EMP TABLE
EMPNO DEPTNO NAME ADDR
DEPTNO
LOCATION
NO_OF_EMPL
DEPT TABLE
Hierarchical Model - Layout
I. Hospital general Info A. Wards and Rooms in each Hospital 1. Patients in each Ward a.Symptoms b.Treatments c.Doctors B. Special Facilities in each Hospital
HIERARCHICAL MODEL
Segment Representation
Hospital
Ward
Facility
Patient
Symptom
Treatment
Doctor
IMS DATABASE
Information Management System. First and Oldest Database developed by IBM. DL/I user interface language
Appl. Program
Appl. Program
DL/I
OS Access methods
OS Access methods
File or dataset
Database
IMS Software Environment
IMS ENVIRONMENT
IMS supports User written Batch Processing and Telecommunication applications. Provides Data Management Services and Data Communication Services. Data Management Services Support multiple applications using a common database. Data Communication Services Support multiple terminal-oriented applications using a common database.
Components of DB & DC
1. Application Program User written programs in COBOL, PL/I, Assembler
2. DB PCB Enables the program to communicate with DL/I to get information from database. 3. DL/I DATA LANGUAGE I Set of IMS program modules. Exists external to the application programs. Allows the application programs to access the database sequentially or randomly. Not a programming language.
APPLICATION PROGRAM
DB PCB
I/O PCB
DL/I
IMS DC
IMS DATABASE
TERMINAL
BATCH MODE PROCESS FLOW
Appl. Program
DB PCB DL/I IMS DB
ON-LINE MODE PROCESS FLOW Terminal
IMS DC
I/O PCB
Appl. program.
DB PCB DL/I IMS DB
IMS Software Environment
IMS DB
OS
DL/I
IMS Control Blocks
IMS DC
Appl Programs
IMS ENVIRONMENT..
IMS database Center of the system. Stored in direct access storage device (DASD).
I/O PCB
- Enable program to communicate with IMS DC
IMS DC communicate with other programs and/or remote terminals. Terminal Interactive on-line applications.
IMS Terminology
IMS - Terminology
Root Top most segment of the database Does not have parent. Parent Segment directly above Child Segment directly below. Segment type Generic term that describes collection of related data.
Twins
All occurrences of a segment type under a single parent. Can be more than two.
Twin chain
Set of twins dependent on a particular parent
Tree structure
No segment can have more than one parent.
Segment
Smallest unit of information that can be retrieved. Maximum of 255 segments.
Field An individual data item. Smallest unit of information in the database Dependent Segment Segments below a particular segment occurrence. Segment occurrence Collection of data items retrieved as a unit.
Hierarchy chart Chart showing the relationship between segments. Database record a single occurrence of a root segment type and all its dependent segments Database Collection of root segment occurrences. Level Position of segment. Maximum 15 levels.
IMS HIERARCHIAL STRUCTURE
20
1
6 5
2
19 7
14
18 15 17 16
10 8
13 11
12
Employee 1
Salary 13 Salary 12 Salary 11 Address X1 Address X2
Address X3
Deduct U
Deduct X Deduct Y Deduct V
Deduct W
Sequential Processing order 1) Top-to-bottom 2) Front-to-back 3) Left-to-right
1-11-X-Y-12-U-V-W-13-X1-X2-X3-2
Physical and Logical data structures
IMS ENVIRONMENT...
DEFINING THE DATABASE
Define segments & hierarchical structure. Choose key and search fields. DBA communicates to IMS. Control block is created DBD. Coding a series of DBDGEN control statements. Consists of Assembler language macro statements.
DEFINING A LOGICAL DATA STRUCTURE
Define logical data structure PSB - Program specification block PCB - Program communication block PCB within one PSB defines one logical data structure for a database PSB generation (PSBGEN) Application Data Structure(PCBs in PSB).
LOOK IN CODING OF DBD. LOOK IN CODING OF PCB.
CODING OF DBD
DBD NAME=EMPLOYEE,ACCESS=(HIDAM,OSAM)
DSGROUP0 DATASET DD1=DDEMP,DEVICE=3380,SIZE=(4096),FRSPC=(10,10) SEGM NAME=EMPDATA,PARENT=0,BYTES=100 FIELD NAME=(EMPID,SEQ,U),BYTES=11,START=1,TYPE=C SEGM NAME=WORKDATA,PARENT=EMPDATA,BYTES=200 FIELD NAME=(DEPTID,SEQ,U),BYTES=5,START=1,TYPE=C
DBDGEN FINISH END
CODING OF PCB
PCB TYPE=DB,DBDNAME=EMPDBD,KEYLEN=16 SENSEG NAME=EMPDATA,PARENT=0,PROCOPT=K SENSEG NAME=WORKDATA,PARENT=EMPDATA,PROCOPT=G PSBGEN LANG=COBOL,PSBNAME=EMPPSB1 END
EMPDATA
WORKDATA
DEPDATA
BENDATA
PCB TYPE=DB,DBDNAME=EMPDB,KEYLEN=16,PROCOPT=G SENSEG NAME=___________,PARENT=___________ SENSEG NAME=___________,PARENT=___________ SENSEG NAME=___________,PARENT=___________ SENSEG NAME=___________,PARENT=___________ PSBGEN LANG=PLI,PSBNAME=EMPPSBY END
IMS Call
AN IMS CALL
Five parts
Call statement to DLI Function code PCB mask IO-AREA Segment Search Argument(s)
Call to DLI
CBLTDLI uses qualifications in form of SSAs Other forms are PLITDLI for PLI ASMTDLI for assembly lang EXECDLI uses where clause for search criteria
PCB MASK
How is PCB mask coded ?
01 XXX- PCB-MASK. 05 XXX-DBD-NAME 05 XXX-SEGMENT-LEVEL 05 XXX-STATUS-CODE 05 XXX-PROC-OPTS 05 XXX-JCB-ADDRESS 05 XXX-SEG-NAME 05 XXX-KEY-LENGTH 05 XXX-NUM-SENS-SEGS 05 XXX-KEY-FBK-AREA PIC X(08). PIC XX. PIC XX. PIC X(04). PIC S9(05) COMP. PIC X(08). PIC S9(05) COMP. PIC S9(05) COMP. PIC X(??).
I/O AREA
standard record description. holds database segments for manipulation. used by DL/I. can be used by the programmer. Area length.
SEGMENT SEARCH ARGUMENT
SEGMENT SEARCH ARGUMENT (SSA) identifies the segment which needs to be accessed SSA is an optional DL/I call parameter can also specify a particular segment type or segment occurrence
Types of SSAs
Unqualified SSA Qualified SSA
SEGMENT SEARCH ARGUMENT..
UN QUALIFIED SSA
only 8 byte segment name is specified 9th position of column is blank. does not indicate a particular occurrence of a segment. accesses the database sequentially.
Qualified SSA
Searches for a specific occurrences of a segment. Has complete information about the segment occurrence supplies either key or search field in addition to segment name
RULES
First field eight chars segment type 9th position identifies the type. When 9th position
( indicates beginning of qualification * SSA includes command codes;qualification ( follows command codes
) indicates end of qualification
SEGMENT SEARCH ARGUMENT
QUALIFIED SSA
EXAMPLE: HOSPITAL(HOSPNAME =RIVEREDGE WARD (WARDNO = 02) PATIENT (PATNAME =BROWN )
)
UN QUALIFIED SSA
EXAMPLE: GU HOSPITAL WARD PATIENT
Operators in Qualified SSA
Equal to Not equal to Less than Less than or equal to Greater than Greater than or equal to = = < <= > >= EQ NE LT LE GT GE
=<
=>
Function Codes
FUNCTION CODES
Four byte-code. Informs DL/I what to do in this call 9 function codes
Function Codes
GU Get Unique. Unique occurrence of a segment. GN Get-Next. Next occurrence of a segment. GNP Get-Next-Within-Parent. Next occurrence of a segment under a parent. Retrieves child segments under a parent.
GHU Get-Hold-Unique. GHN Get-Hold-Next. GHNP Get-Hold-Next-within-Parent.
REPL REPLace. Replace an occurrence of a segment. DLET DeLETe. Delete an occurrence of a segment. ISRT InSeRT. Insert an occurrence of a segment.
DELETING, UPDATING, INSERTING SEGMENTS
Rules for DELETING/UPDATING of segments Issue Get-Hold call. No intervening calls(using the same database PCB MASK). No SSAs in the call. Do not modify the key field.
DELETE,REPLACE,INSERT CALLS
SYNTAX TO DELETE GHU HOSPITAL(HOSPNAME= MAC NEAL WARD (WARDNO = 01) PATIENT (BEDIDENT=0003) DLET SYNTAX TO REPLACE GHU HOSPITAL(HOSPNAME=MAC NEAL WARD (WARDNO =04) REPL SYNTAX TO INSERT ISRT HOSPITAL(HOSPNAME=MAC NEAL WARD (WARDNO =04) PATIENT )
STATUS CODES
STATUS CODE DL/I call statement is executed a status code is generated. Code is based on the type of the call. FOR GET-NEXT CALLS:
With Qualified SSAs.
Blank successful retrieval call. GE For segment not found. Without SSAs. GA Moved up in level. GK New segment type encountered at same level. GB End of the database encountered.
FOR INSERT CALLS: II Segment already exists. IL Insert rule violation.
FOR INSERT STATUS CODES FOR LOADING CALLS: LB Segment already exists. LC Key value out of sequence. LD No parent for segment being loaded. LE Segment type out of sequence.
FOR DLET/REPL CALLS:
DJ DA DX RX
No previous GET-HOLD call. Key field modified. Delete rule violation. Replace rule violation.
Command Codes
COMMAND CODES
Request a number of useful IMS functions. used to save programming and processing time. Number of SSAs reduced. IMS to modify the way the call is handled. There are ten command codes.
COMMAND CODES..
D Put this segment into the I/O area (Path Call). N do not replace this segment. C Concatenated key in SSA. F Locate the first occurrence. L Locate the last occurrence. P Establish the Parentage at this level. Q En-queue this segment . U Maintain current position at this level. V Maintain current position here and higher level. -Null command code.
COMMAND CODES
EXAMPLES: QUALIFIED SSAs
WARD *D(WARDNO =04) PATIENT *DNP(PATNAME =SMITH )
UN QUALIFIED SSAs
WARD *D PATIENT *DN
COMMAND CODES..
D & N Command Code : AIM : To print hospital and ward information for a
patient and we also want to update the patient segment. Without Command Codes
Step1: Step2: Step3: Step4: GU HOSPITAL(HOSPNAME =RIVEREDGE ) GN WARD (WARDNO =02) GHU PATIENT(BEDIDENT =0003) REPL
With Command Codes Step1: Hold call GHU HOSPITAL*D(HOSPNAME =RIVEREDGE WARD *D(WARD =02) PATIENT (BEDIDENT =0003) Step 2: Replace call REPL HOSPITAL*N(HOSPNAME =RIVEREDGE WARD *N(WARDNO =02) PATIENT (BEDIDENT =0003)
COMMAND CODES...
Combination of D&N command codes
HOSPITAL*DN(HOSPNAME =RIVEREDGE )
WARD *DN(WARDNO =02) PATIENT (BEDIDENT =0003)
Using C command code (Concatenation)
With out command code GHU HOSPITAL(HOSPNAME =RIVEREDGE ) WARD (WARDNO =02) PATIENT (BEDIDENT =0003) DOCTOR (DOCTNAME =BOSWELL ) With command code
GHU DOCTOR *C(RIVEREDGE
020003BOSWELL
A Simple Batch IMS COBOL Program
A COBOL-IMS application program structure
Working Storage I/O Areas ( Segments to and from Database) Segment Search Arguments Qualified or Unqualified Linkage Section PCB Area (Return information from DLI) Procedure Division
DL/I Modules
Program Entry
Calls to DL/I (Get, Insert, Replace, Delete) Processing Termination
DL/I Area
COBOL CODING USING IMS
IDENTIFICATION DIVISION. PROGRAM-ID. ENVIRONMENT DIVISION. * DATA DIVISION. * 01 INFILE. 03 HOSPNAME-IN PIC X(20). 03 WARDNO-IN PIC X(2). 03 PATIENT-IN PIC X(20). * WORKING-STORAGE SECTION. 77 GET-UNIQUE PIC XXXX VALUE GU . 01 HOSPITAL-SSA. 03 FILLER PIC X(19) VALUE HOSPITAL(HOSPNAME =. 03 HOSPNAME-SSA PIC X(20). 03 FILLER PIC X VALUE ). 01 WARD-SSA. 03 FILLER PIC X(19) VALUE WARD (WARDNO =. 03 WARDNO-SSA PIC X(2). 03 FILLER PIC X VALUE ).
COBOL CODING USING IMS..
01 PATIENT-SSA. 03 FILLER PIC X(19) VALUE PATIENT (PATNAME =. 03 PATNAME-SSA PIC X(20). 03 FILLER PIC X VALUE ). 01 IO-AREA COPY PATIENT. LINKAGE SECTION. 01 PCB-MASK COPY MASKC. PROCEDURE DIVISION. ENTRY-LINKAGE. ENTRY DLITCBL USING PCB-MASK. PROG-START. OPEN INPUT INFILE. OPEN OUTPUT OUTFILE. READ-INPUT. READ INFILE AT END GO TO END-OF-JOB. MOVE HOSPNAME-IN TO HOSPNAME-SSA. MOVE WARDNO-IN TO WARDNO-SSA. MOVE PATNAME-IN TO PATNAME-SSA. CALL CBLIDLI USING GET-UNIQUE PCB-MASK IO-AREA HOSPITAL-SSA
COBOL CODING USING IMS...
WARD-SSA PATIENT-SSA. IF STATUS-CODE EQUAL TO GE OR GB MOVE STATUS-CODE TO DUMP-AREA MOVE PATIENT NOT FOUND TO PRINT-PATIENT-NAME ELSE IF STATUS CODE NOT = SPACES DISPLAY ERROR IN DATABASE READ STATUS-CODE CALL DUMP END-IF END-IF. PERFORM PRINT-ROUTINE. GO TO READ-INPUT. PRINT-ROUTINE. . END-OF-JOB. CLOSE INFILE. CLOSE OUTFILE. GOBACK.
COBOL CODING USING IMS...
01 HOSPITAL. 03 HOSPNAME 03 HOSP-ADDR 01 WARD. 03 WARDNO 03 BEDAVAIL 01 PATIENT. 03 PATNAME 03 PAT-ADDRESS 01 SYMPTOM. 03 DIAG 03 STMP-DATE 01 TREATMENT. 03 TRTYPE 03 TRDATE 01 DOCTOR. 03 DOCNAME 03 DOCADDRESS
PIC X(20). PIC X(30).
PIC XX. PIC XXX. PIC X(20). PIC X(30). PIC X(20). PIC X(30). PIC X(20). PIC X(10). PIC X(20). PIC X(30).
Multiple Positioning
Multiple Positioning
Single Positioning Multi-Positioning Retrieving a set of child segments for each parent
Hospital database
Hospital
Ward
Facility
Patient
Symptom
Treatment
Doctor
MULTI POSITIONING
GU HOSPITAL(HOSPNAME =XXX WARD (WARDNO = 01) PATIENT (BEDIDENT =1012) )
GNP SYMPTOM GNP TREATMENT GNP DOCTOR SINGLE POSITIONING FAILS HERE.. GNP SYMPTOM GNP TREATMENT GNP DOCTOR
MULTI POSITIONING
PCB TYPE=DB,NAME=HOSPITAL, POS=M POS parameter POS = M POS =S IMS maintains separate position within a data record for each dependent segment type
Secondary Indexing
Secondary Indexing
A self contained database stores a series of pointers to segments of database being indexed processing other than the key sequence
Secondary Indexing Terminology
Index database PROCSEQ parameter Indexed field Index source segment Index target segment Index pointer segment
Indexed field + a pointer to target segment
A Secondary Index
Index target - Patient Index Source - Symptom Indexed fields - Diagnose+Prescription (XDIAG)
WARD HOSPITAL
FACILITY
PATIENT
DIAGINDX
SYMPTOM TREATMNT DOCTOR
Using Secondary Index
PCB TYPE = DB, NAME=HOSPITAL PROCOPT=A,PROCSEQ=DIAGINDX 1. GN HOSPITAL retrieves in DIAGNDX sequence 2. GU PATIENT(XDIAG =XXXX1231) uses DIAGINDX to retrieve the required segment using the indexed field.
Using Secondary Index
SENSEG NAME=HOSPITAL,PARENT=0,INDICES=DIAGINDX
1. GN HOSPITAL retreives the in normal sequence 2. GU PATIENT(XDIAG = xxxx1234 ) retreives using DIAGINDX with the index key.
Secondary Index Restrictions
Any type of calls can be issued on segments below index target segment DLET or ISRT calls cannot be made for index target segment or any of its parents in original hierarchy
Independent-AND
Can be used to retrieve data where more than one index pointer segment can point to a given index target segment.
GU PATIENT(XDIAG = PLAGUE GU PATIENT(XDIAG = PLAGUE * XDIAG = FLU # XDIAG = FLU ) )
Secondary Indexing
A INDEX1 C B
INDEX2
E
G B A G
PCB PROCSEQ=INDEX1
PCB PROCSEQ=INDEX2
Secondary Indexing Relationships
Secondary index and the database may have one to one relationship
Index pointer segments have unique key fields
one to many relationship
Index pointers segments does not have the key field as unique
Logical databases and Logical Relationships
Logical Relationships - A Snapshot
Restructuring the hierarchy Connecting the physical databases Reduce redundancy of segments in different databases
Logical database terms
Logical child Logical parent Logical database Logical Twins
An Example
HOSPITAL NAME
WARD
FACILITY
BILLING
HISTORY
PATIENT
SYMPTOM
TREATMNT
DOCTOR
Pointer segment
Logical Relationships - Types
Unidirectional Bi-directional
bi-directional virtual logical relationship bi-directional physical logical relationship
Logical databases
NAME SKILL
ADDRESS
PAYROLL
NAME
EXPR
EDUC
Payroll database (Physical)
Skills database (Physical)
Logical databases
NAME SKILL
2 physical databases
Are merged in to
LOGICAL DBDGEN
Produce a logical dbd
NAMESKIL
The PCB (and program) use the name of the logical database
MYPSB
Logical database
SKILL
NAME
EXPR
EDUC
ADDRESS
PAYROLL
Logical database
NAME
ADDRESS
PAYROLL
SKILL
EXPR
EDUC
Variable Length Segments
Variable Length Segments
save space two byte length field
Length 1 2 3 data
Variable Length Segment
Variable Length Segment
SEGM NAME=TREATMENT, PARENT=PATIENT,BYTES=(160,90) 160 90 Maximum size of segment Minimum size of segment
Generalized Sequential Access Method
GSAM
Access to standard sequential dataset or VSAM ESDS using IMS calls no hierarchical structure no key or search fields
GSAM call
Call CBLTDLI USING GET-NEXT GSAM-PCB I-O-AREA GSAM-RSA.
DL/I Recovery & Restart Features
Terms for discussion
Abnormal Termination routines IMS Log Recovery
forward recovery backward recovery
Checkpointing
Other terms -checkpoint,sync point, commit point, point of integrity Checkpoint call - CHKP Types of checkpointing
basic checkpointing symbolic checkpointing with extended restart facility
Basic Checkpointing
Linkage Section. 01 I-O-PCB-MASK. 05 FILLER PIC X(10)
05 I-O-PCB-STATS-CODE PIC XX.
CALL CBLTDLI USING
DLI-CHKP I-O-PCB-MASK CHECKPOINT-ID
Symbolic Checkpointing
Working Storage Section. 01 COUNT-FIELDS . 01 PRINT-FIELDS ... 01 CHECKPOINT-ID PIC S9(08) COMP. 01 RESTART -WORK-AREA PIC X(12) VALUE SPACES.
01 LENGTH FIELDS
COMP. VALUE +11. VALUE + 9.
05 LENGTH-COUNT-FIELDS PIC S9(5) 05 LENGTH-PRINT-FIELDS PIC S9(5)
05 LENGTH-LONGEST-SEGMENT PIC S9(5) VALUE + 128.
LINKAGE SECTION. 01 I-O-PCB. 05 FILLER PIC X(10). PIC X(2).
05 I-O-PCB-STATUS-CODE
..
PROCEDURE DIVISION. ENTRY DLITCBL USING I-O-PCB . CALL CBLTDLI USING DLI-XRST I-O-PCB LENGTH-LONGEST-SEGMENT RESTART-WORK-AREA
LENGTH-COUNT-FIELDS
COUNT-FIELDS LENGTH-PRINT-FIELDS PRINT-FIELDS. IF I-O-PCB-STATUS-CODE NOT = SPACE DISPLAY RESTART-FAILED -- STATUS CODE : I-O-PCB-STATUS-CODE ELSE IF RESTART-WORK-AREA NOT= SPACES PERFORM 100-REPOSITION-DATA-BASE.
230-ISSUE-CHECKPOINT-CALL.
ADD 1 TO CHECKPOINT-ID. CALL CBLTDLI USING DLI-CHKP I-O-PCB
LENGTH-LONGEST-SEGMENT
CHEKPOINT-ID LENGTH-COUNT-FIELDS COUNT-FIELDS LENGTH-PRINT-FIELDS PRINT-FIELDS. IF I-O-PCB-STATUS-CODE NOT =SPACE DISPLAY CHECKPOINT FAILED -- STATUS CODE: I-O-PCB-STATUS-CODE ..
General Structure of an Online Program
Get twa. IF twa-save-area not = low values ****the control to this program has come from a different transaction Get the some information from TWA process the details from TWA Load the map send it and return. else if eibcalen > 0 (check commarea) ****the program is in pseudoconversation get information from commarea receive map process the details on the map send it and return else *****program is invoked for the first time from screen Load the map with default values send the map and return.