IMSDB Data
Transcript of IMSDB Data
Information Management System
IMS
DatabasesWhat 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 MODELEMP TABLE
DEPT TABLE
EMPNO ADDR
LOCATION NO_OF_EMPL
DEPTNO NAME
DEPTNO
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 MODELSegment Representation
S ym p tom Trea tm en t D oc to r
P a tien t
W ard F ac ility
H osp ita l
IMS DATABASE
• Information Management System.
• First and Oldest Database developed by IBM.
• DL/I user interface language
DL/I
OS Access methods
Appl. Program
OS Access methods
File or dataset
Appl. Program
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
DL/I
IMSDATABASE
I/O PCB
IMS DC
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 DB
OS
DL/I
IMS Control Blocks
Appl Programs
IMS DC
IMS Software Environment
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
1
2
3
4
5
6
7
8
9
1011
12
13
14
15
1617
18
19
20
Employee1
Salary13
Salary12
Salary11
DeductY
DeductX
DeductW
DeductV
DeductU
AddressX3
AddressX2
AddressX1
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=GSENSEG NAME=___________,PARENT=___________ SENSEG NAME=___________,PARENT=___________SENSEG NAME=___________,PARENT=___________ SENSEG NAME=___________,PARENT=___________ PSBGEN LANG=PLI,PSBNAME=EMPPSBYEND
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 PIC X(08).
05 XXX-SEGMENT-LEVEL PIC XX.
05 XXX-STATUS-CODE PIC XX.
05 XXX-PROC-OPTS PIC X(04).
05 XXX-JCB-ADDRESS PIC S9(05) COMP.
05 XXX-SEG-NAME PIC X(08).
05 XXX-KEY-LENGTH PIC S9(05) COMP.
05 XXX-NUM-SENS-SEGS PIC S9(05) COMP.
05 XXX-KEY-FBK-AREA 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 SSAEXAMPLE:
GU HOSPITAL
WARD
PATIENT
Operators in Qualified SSA
Equal to = EQ
Not equal to ¬= NE
Less than < LT
Less than or equal to <= =< LE
Greater than > GT
Greater than or equal to >= => 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 No previous GET-HOLD call.
• DA Key field modified.
• DX Delete rule violation.
• RX 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: GU HOSPITAL(HOSPNAME =RIVEREDGE )
Step2: GN WARD (WARDNO =02)
Step3: GHU PATIENT(BEDIDENT =0003)
Step4: 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 StorageI/O Areas ( Segments to and from Database)
Segment Search ArgumentsQualified or Unqualified
Linkage SectionPCB Area (Return information from DLI)
Procedure Division
Program Entry
Calls to DL/I (Get, Insert, Replace, Delete)
Processing Termination
DL/I Modules
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 PIC X(20).
03 HOSP-ADDR PIC X(30).
01 WARD.
03 WARDNO PIC XX.
03 BEDAVAIL PIC XXX.
01 PATIENT.
03 PATNAME PIC X(20).
03 PAT-ADDRESS PIC X(30).
01 SYMPTOM.
03 DIAG PIC X(20).
03 STMP-DATE PIC X(30).
01 TREATMENT.
03 TRTYPE PIC X(20).
03 TRDATE PIC X(10).
01 DOCTOR.
03 DOCNAME PIC X(20).
03 DOCADDRESS PIC X(30).
Multiple Positioning
Multiple Positioning
• Single Positioning
• Multi-Positioning
• Retrieving a set of child segments for each parent
Hospital database
S ym p tom Trea tm en t D oc to r
P a tien t
W ard F ac ility
H osp ita l
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 segmentIndexed field + a pointer to target segment
A Secondary Index
HOSPITAL
WARD FACILITY
PATIENT
TREATMNTSYMPTOM DOCTOR
DIAGINDX
• Index target - Patient
• Index Source - Symptom
• Indexed fields - Diagnose+Prescription
• (XDIAG)
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 * XDIAG = FLU )
GU PATIENT(XDIAG = PLAGUE # XDIAG = FLU )
Secondary IndexingA
B C
D
F
E
G
INDEX1
INDEX2
A
B
E
GPCB … PROCSEQ=INDEX1
PCB … PROCSEQ=INDEX2
Secondary Indexing Relationships
Secondary index and the database may have
• one to one relationshipIndex pointer segments have unique key fields
• one to many relationshipIndex 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
WARD FACILITY
PATIENT
TREATMNTSYMPTOM DOCTOR Pointersegment
NAME
BILLING HISTORY
Logical Relationships - Types
• Unidirectional
• Bi-directional– bi-directional virtual logical relationship– bi-directional physical logical relationship
Logical databases
NAME
ADDRESS PAYROLL NAME
EXPR EDUC
SKILL
Payroll database (Physical) Skills database (Physical)
Logical databasesNAME SKILL
LOGICAL DBDGEN
NAMESKIL
MYPSB
2 physical databases
Are merged in to
Produce a logical dbd
The PCB (and program) use the name of the
logical database
Logical database
NAME
EXPR EDUC
SKILL
ADDRESS PAYROLL
Logical database
NAME
ADDRESS PAYROLL
EXPR EDUC
SKILL
Variable Length Segments
Variable Length Segments
• save space
• two byte length field
dataLength
1 2 3
Variable Length Segment
Variable Length Segment
SEGM NAME=TREATMENT, PARENT=PATIENT,BYTES=(160,90)
160 Maximum size of segment
90 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 CheckpointingLinkage 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 CheckpointingWorking 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.
05 LENGTH-COUNT-FIELDS PIC S9(5) VALUE +11.
05 LENGTH-PRINT-FIELDS PIC S9(5) VALUE + 9.
05 LENGTH-LONGEST-SEGMENT PIC S9(5) VALUE + 128.
LINKAGE SECTION.
01 I-O-PCB.
05 FILLER PIC X(10).
05 I-O-PCB-STATUS-CODE PIC X(2).
…..
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.