IMSDB Data
IMSDB Data
IMSDB Data
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
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 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
Appl. Program
DB PCB DL/I IMS DB
Appl. program.
DB PCB DL/I IMS DB
OS
DL/I
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.
6 5
2
19 7
14
18 15 17 16
10 8
13 11
12
Employee 1
Address X3
Deduct U
Deduct X Deduct Y Deduct V
Deduct W
1-11-X-Y-12-U-V-W-13-X1-X2-X3-2
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.
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
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.
Types of SSAs
Unqualified SSA Qualified SSA
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
UN QUALIFIED SSA
EXAMPLE: GU HOSPITAL WARD PATIENT
=<
=>
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.
REPL REPLace. Replace an occurrence of a segment. DLET DeLETe. Delete an occurrence of a segment. ISRT InSeRT. Insert an occurrence of a segment.
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:
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 )
020003BOSWELL
DL/I Modules
Program Entry
Calls to DL/I (Get, Insert, Replace, Delete) Processing Termination
DL/I Area
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
A Secondary Index
Index target - Patient Index Source - Symptom Indexed fields - Diagnose+Prescription (XDIAG)
WARD HOSPITAL
FACILITY
PATIENT
DIAGINDX
SYMPTOM TREATMNT DOCTOR
1. GN HOSPITAL retreives the in normal sequence 2. GU PATIENT(XDIAG = xxxx1234 ) retreives using DIAGINDX with the index key.
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
Restructuring the hierarchy Connecting the physical databases Reduce redundancy of segments in different databases
An Example
HOSPITAL NAME
WARD
FACILITY
BILLING
HISTORY
PATIENT
SYMPTOM
TREATMNT
DOCTOR
Pointer segment
Logical databases
NAME SKILL
ADDRESS
PAYROLL
NAME
EXPR
EDUC
Logical databases
NAME SKILL
2 physical databases
Are merged in to
LOGICAL DBDGEN
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
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.
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)
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
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.
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 ..