Top Banner
IMS / DB
37
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: IMS DB Fundamentals Latest

IMS / DB

Page 2: IMS DB Fundamentals Latest

2IMS Fundamentals

What is a Database System?

• “ A system that allows multiple independent users to have concurrent access

to a central repository of information …”

• Advantages– Centralized files for all applications– Elimination of duplicate space and effort– Single information source provides complete accurate information

processing– Concurrency and easily manageable.

Page 3: IMS DB Fundamentals Latest

3IMS Fundamentals

Types of DBMS

1. Hierarchical

A hierarchical database is a kind of database management system that links records together in a tree data structure such that each record type has only one owner, e.g. an order is owned by only one customer. Hierarchical structures were widely used in the first mainframe database management systems. However, due to their restrictions, they often cannot be used to relate structures that exist in the real world.

Page 4: IMS DB Fundamentals Latest

4IMS Fundamentals

Types of DBMS (Contd..)

2. Network

The network model is a database model conceived as a more flexible alternative to the hierarchical model. Where the hierarchical model structures data as a tree of records, with each record having one parent record and many children, the network model allows each record to have multiple parent and child records, forming a lattice structure.

Page 5: IMS DB Fundamentals Latest

5IMS Fundamentals

Types of DBMS (Contd..)

3. Relational

A relational database is organized into tables, in which data is defined so that it can be reorganized and accessed in a number of

different ways without having to reorganize the database tables.

Page 6: IMS DB Fundamentals Latest

Relational VS. Hierarchical

Because the data relationships in a hierarchical structure are pre-defined., its major advantage is speed of access. The major disadvantage is the reduced flexibility inherent in a pre-defined structure. The IBM hierarchical product is IMS/DB.

Relational databases are much more flexible and are generally easy to use. However , The increased flexibility can result in slower access times .The IBM relational product is DB2

6IMS Fundamentals

Page 7: IMS DB Fundamentals Latest

7IMS Fundamentals

What is IMS?

• IMS (Information Management System) is IBM's hierarchical database product

• Hierarchical Data base management system that supports the application program while processing data bases in batch or on-line environments.

• IMS maintains an Inverted Tree Structure starting with the Root Segment by ensuring that no segment has more than one parent.

• The Hierarchy can go up to fifteen levels down.

• The Hierarchy can represent up to 255 segment types

Page 8: IMS DB Fundamentals Latest

8IMS Fundamentals

Characteristics Of An IMS Database

An IMS database consists of some number of database records. The size of the

database is limited only by the constraint of VSAM and DASD.

A maximum of 15 levels are allowed; a level can be defined as all segments that have

the same number of segments above them. The root segment is always level one.

Each immediate child of the root is level two and so on .IMS allows up to 255 different

segment types in a single database.

Page 9: IMS DB Fundamentals Latest

9IMS Fundamentals

Why IMS?

Advantages:

• Large Volumes of Data can be handled• Faster Access of Data• Can be combined with DB2 for making data retrieval efficient (DB2 for

querying and IMS for processing)• Checkpoint restart feature available.

Limitations:• Not many tools for IMS compared to DB2 (File aid ~ file structure on pc) • Rigid design of IMS doesn’t make it programmer friendly

Page 10: IMS DB Fundamentals Latest

Access Types• HSAM/SHSAM (Simple /Hierarchic sequential Access Method) : The

segments that make up the database record are related to one another by their physical locations (SHSAM has only root occurrences)

• HISAM/SHISAM (Simple / Hierarchic Indexed Sequential Access Method) :The data is stored with hierarchic sequential organization along with an index for random processing (SHISAM has only index of root occurrences)

• HDAM (Hierarchic Direct Access Method) :The segment occurrences include prefixes that contain the direct address pointers to related segment - stores root segment occurrences

• HIDAM (Hierarchic Indexed Direct Access Method) : Similar to HDAM but stores an index of the root segment occurrences

10IMS Fundamentals

Page 11: IMS DB Fundamentals Latest

11IMS Fundamentals

IMS – Components

• Five components of IMS Environment

1. Database Management System – Is the heart of IMS subsystem. Shared by many concurrent tasks. Data is stored in DASD. Application programs access data by making DL/I calls.

2. DL/I (Data Language Interpreter) – Is a set of program modules interfacing database and application program. The modules use standard operating system access methods and a set of specialized access methods to handle data transfers to and from the database. Is an interface language used by the application program.

Page 12: IMS DB Fundamentals Latest

12IMS Fundamentals

IMS – Components (Contd..)

3. DL/I Control Blocks - There are two main DL/I control blocks – namely, Database Descriptor (DBD) which describes the database structure and Program Communication Block (PCB) which identifies how the database may be accessed by the program.

4. Application Program – Are designed and coded by the programmers. Programs use a standard DL/I interface to other IMS components. DL/I application programs use standard CALL statements with a parameter list to communicate with IMS. Programs may be written in COBOL, PL/I and ASM. Eg: first stmt in IMS program DLITCBL, all subsequent calls are CBLTDLI.

Page 13: IMS DB Fundamentals Latest

13IMS Fundamentals

IMS – Components (Contd..) & Features

5. Data Communication – Is a set of program modules that allow the program to communicate with remote terminals. Programs communicate with terminals through a Standard Interface Language using CALL statements with a parameter list.

• Primary Products – IMS/ESA Transaction Manager – IMS/TM– IMS/ESA Database Manager – IMS/DB

• Product Implementations– DC is used to implement the transaction manager– DB is used to implement the database manager

Page 14: IMS DB Fundamentals Latest

14IMS Fundamentals

Traversal in IMS database

• IMS database traversal generally follows:– Top to bottom– Left to right– Front to back

• Illustration follows:

Page 15: IMS DB Fundamentals Latest

15IMS Fundamentals

Explanation of diagram

• The diagram shows how the data elements are arranged in IMS. Data elements are stored in the hierarchical structure or in other way we can say that some data elements are dependent on other.

• Each grouping of data is called as segments.

• A segment is the unit of data that DL/I transfers to and from your program.

• In previous diagram DEALER, MODEL, ORDER, STOCK and SALES are the names of segments.

Page 16: IMS DB Fundamentals Latest

Definitions

• Segment - Unit of Information handled in IMS

- Unit of data transferred from DL/I in an IO operation

- Consists of fields, key fields & Search fields

• Occurrence - Specific segment of a particular type of segment

- Contains actual user data

• Root Segment - Top of the hierarchy

- All other segments are derived from the root

• Parent Segment - Segment that has dependent segments

16IMS Fundamentals

Page 17: IMS DB Fundamentals Latest

Definitions (contd)• Child Segment - A dependent segment

• Segment Level - Depth of an IMS structure

- Root is at Level 0, max 15 levels, max 255 segments

• Path - Series of segments from Root to the child

• Database record - Each occurrence of the Segment Plus all

occurrence of the subordinate segments

• Twins - Segment occurrences of same type with same parent

segment occurrence

17IMS Fundamentals

Page 18: IMS DB Fundamentals Latest

18IMS Fundamentals

Concept of Segments

• In IMS, segments are defined by the order in which they occur and by their relationship with other segments.

• The segment type at the top level of Hierarchy represents the Root segment. Like in the above case the DEALER represents the root segment.

• An occurrence of the root segment plus all the segment occurrences subordinate to it makes one database record.

• All of the segments except the root segment are called dependent segments. Each dependent segment is also called the child segment.

Page 19: IMS DB Fundamentals Latest

19IMS Fundamentals

Terms in an IMS Database

• SEGMENT or SEGMENT TYPE

- A segment is the smallest structure of the database in the sense that IMS cannot retrieve data in an amount less than a segment

- Within each segment there can be one or more data fields - A database record can contain a maximum of 255 types of segments and one hierarchical path can have up to 15 segment types

• FIELDS

- Segments can be broken down into smaller increments called fields, which can be addressed individually by application programs

Page 20: IMS DB Fundamentals Latest

20IMS Fundamentals

Terms in an IMS Database (Contd..)

• SEGMENT OCCURANCE

- Segment Occurrence identifies the data that belongs to a particular Segment Type

• PARENT

- A segment that has one or more dependant segments beneath it in the hierarchy.

• CHILD

- A segment that is a dependent on another segment above it in the hierarchy.

Page 21: IMS DB Fundamentals Latest

21IMS Fundamentals

Terms in an IMS Database (Contd..)

• TWINS - All occurrences of a particular segment type under a single parent

segment occurrence are called TWINS

• DATABASE (IMS) - A database consists of all root segment occurrences along with their dependents.- Is normally shared by multiple applications.

• DATABASE RECORD - A database record has one root segment occurrence along with all the

occurrences of its child segments in hierarchic sequence

Page 22: IMS DB Fundamentals Latest

22IMS Fundamentals

Organization and Access Methods

• Organization The way data is organized. e.g. KSDS,ESDS,RRDS,LDS

• Access MethodThe process followed to access the data. E.g. VSAM

• IMS Access Methods are– Hierarchic sequentially accessed databases HSAM, SHSAM, HISAM, SHISAM, GSAM– Hierarchic direct databases HDAM, HIDAM– Fast Path databases provide fast access with limited functionality DEDB, MSDB

Page 23: IMS DB Fundamentals Latest

23IMS Fundamentals

Control Blocks

• IMS uses two kinds of control blocks to enable application programs

– The database descriptor/definition (DBD) and

– Program communication block (PCB).

Database Description (DBD)

A database descriptor (DBD) is a control block that describes the physical structure of the database. The DBD also defines the appearance and contents, or fields, that make up each of the segment types in the database. It describes the way in which it is stored on the DASD and the way it is accessed.

Page 24: IMS DB Fundamentals Latest

24IMS Fundamentals

Control Blocks (Contd..)

Program Communication Block (PCB)

A program communication block (PCB) defines an application program's view of the database. It describes the logical structure of a database as a particular program views it. It identifies which pieces of a data a program is allowed to access and the kinds of functions (operations) it can perform on each collection of data. This is useful when an application program needs to process only some of the segments in a database which is a very common need.

Page 25: IMS DB Fundamentals Latest

25IMS Fundamentals

What is DL/I ?

DL/I is Data Language Interpreter is a data management facility that serves as an interface between an application program and a database.

Page 26: IMS DB Fundamentals Latest

26IMS Fundamentals

DBD - Data base definition

DBDA database description/definition (DBD) is a series of macro

statements that define the type of database, all segments and fields, and any

logical relationships or indexing. DBD macro statements are submitted to the DBDGEN utility, which generates a DBD control block and stores it in the IMS.DBDLIB library for use when an application program

accesses the database.

Apart from describing the physical structure and interdependency of segments in database, it also names the DBD and the access method

that will be used by DL/I for data manipulation.

Page 27: IMS DB Fundamentals Latest

27IMS Fundamentals

Defining DBD

• Suppose the ACCENTURE hierarchical structure has been designed. The name of the segments has been chosen. Now we must tell IMS about this database. IMS needs to know about all the keys, search fields, and relationships that are designed as part of the organization database.

• The DBD is usually coded by a DBA (Data Base Administrator). It is then submitted to the system with JCL that invokes a procedure called DBDGEN. This procedure produces an object module which is in turn passed to the linkage editor which produces a load module. The load module is stored in a library named something like IMSVS.DBDLIB.

Page 28: IMS DB Fundamentals Latest

28IMS Fundamentals

DBD Functions

• Defines the physical storage information.• Defines the hierarchical structure.• Define the relationship between the segments.• Defines the segment layouts.• Defines the key field with in the segment. • Describe the information necessary to create the database. • Defines any logical relationship.• Defines the secondary index.

Page 29: IMS DB Fundamentals Latest

29IMS Fundamentals

DBD - Data base definition – Macros

• DBD Names the database being described and specifies its organization.

• DATASET Specifies the names of files used to store the data. Defines

each file which comprises the data base. It defines the DD names and the dataset information.

• SEGM Defines the name of the segment type, its position in the data base and how it is related to other segments.• LCHILD Defines a relationship between two different segment

types. This could be an index relationship, a logical relationship or a secondary index.

• FIELD Defines a field within a segment. It identifies the field name, its length in bytes, its starting position, and the type of data in the field.

Page 30: IMS DB Fundamentals Latest

30IMS Fundamentals

DBD-Data base definition Macros (Contd..)

• XDFLD Defines the source fields for a secondary index.

• DBDGEN This statement ends the SEGM and FIELD definitions for the DBD. Marks the end of statements defining the DBD.

• END This statement marks the end-of-data to the assembler process.

Page 31: IMS DB Fundamentals Latest

31IMS Fundamentals

Some common status codes

• SPACES – successful retrieval.• GB – End of database.• GE – Not found.• II – Duplicate segment while insertion.• DA – Key field changed.• DJ – No get hold call before DLET or REPL.• GK – Segment of diff type but at the same hierarchical level. • GA – Higher level segment was retrieved during sequential

call.

Page 32: IMS DB Fundamentals Latest

32IMS Fundamentals

Command Codes

The 10 Command Codes available in IMS are :

• C Concatenated key in the SSA.

• D Retrieve this segment data into the I-O Area (Path call).

• F Locate the first segment occurrence that satisfies the SSA.

• L Locate the last segment occurrence that satisfies the SSA.

• N Do not replace this segment.

• Q Locks a segment for your program's exclusive use.

Page 33: IMS DB Fundamentals Latest

33IMS Fundamentals

Command Codes (Contd..)

• U Specify the current database positions at that level is not allowed to be changed by the call

• P Establish Parentage at this level

• V Specify the current database position at that & all levels above are not allowed to be changed by the call

• 'NULL‘ Used as the place holder in SSA's so that command codes can be removed/inserted from SSA's without having to define

separate SSA's in working storage.

Page 34: IMS DB Fundamentals Latest

34IMS Fundamentals

Some more DL/I Status codes

• AB The call did not specify a segment IO area• AC SSA with a hierarchical error• AH Call requires at least one SSA• AJ Call specifies an Invalid SSA• AI Error encountered when trying to open the database

dataset. An error in the JCL DD statement• AK The field named in a qualified SSA is not correct• AT The IO area specified in the call is too large but the

program’s PSB may be incorrect• AO Call caused an operation resulting in a physical IO error

Page 35: IMS DB Fundamentals Latest

35IMS Fundamentals

System Service – DL/I Calls

The four important DL/I calls that perform various system service functions are : 1) CHKP 2)XRST 3)ROLL 4)ROLB

CHECKPOINT (CHKP) Call • A point in the execution of program when the changes made to the

database are considered complete and accurate.• Checkpoint (CHKP) call is used for recovery purposes, in the IMS

programming environment it is the method used to ensure data integrity. • Once check pointed, the changes made are not reversible.• CHKP call causes all the database changes made since the last

checkpoint to be permanently committed to the physical database thereby making Backout impossible.

• A CHKP call causes the database position for a PCB to be reset, apart from releasing all the locks held by the program.

Page 36: IMS DB Fundamentals Latest

36IMS Fundamentals

System Service – DL/I Calls (Contd..)

• In addition, the CHKP call

– Enables you to save as many as seven data areas in your program, which are restored when your program is restarted

– In case of ABENDs, IMS will control the process of backing out database updates up to the last checkpoint.

– Works with the Extended Restart (XRST) call to restart your program if it terminates abnormally

Page 37: IMS DB Fundamentals Latest

37IMS Fundamentals

Checkpoint Restart

Why checkpointing?

– If there are other jobs updating or reading the tables, there should be a checkpoint at an interval < the DB2 timeout interval (typically 30 seconds will suffice).

– When A large amount of locking activity is taking place. Locks are a finite resources in a DB2 Subsystem.

– When we do not want to lose work already accomplished. If a job runs a long time, recovery is not just re-running the job, but also waiting for DB2 to roll back changes.

– Checkpoint intervals are based on the situation. For example, if online activity is present, or we are running parallel processes, checkpoints should be taken at 10 second intervals. If we are running stand alone batch, and have exclusive access to our tables, we might go as high as 60 seconds.