You are on page 1of 67

IDMS Application Programming

Pre-requisites
MVS and TSO/ISPF subsystem
JCL & VSAM concepts Programming in COBOL

Course Contents
Introduction to DBMS Record Characteristics Set Characteristics IDD and DDDL Data Description Language (DDL) Data Manipulation Language (DML) Recovery & Restart of Database Locking Facilities

UNIT 1
Introduction to DBMS

Objectives
Participants will be able to learn: Basic concept of DBMS and the types of DBMS systems. Logical and Physical Database Structure.

DBMS
Database Management System (DBMS) is a set of computer programs that controls the creation, maintenance, and the use of a database. It allows organizations to place control of database development in the hands of database administrators (DBAs) and other specialists. A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases.

Types OF DBMS
Hierarchical (e.g. IMS) Data records are typically connected with embedded pointers to form a tree structure. Each node (except root) can have one and only one parent. Network (e.g. IDMS) The database forms a mesh structure EntityRelationship is implemented using Record type and Set.
7

Types OF DBMS(contd..)
Relational (e.g. Oracle, Sybase, DB2,etc) Entity-Relationship is implemented in the normalized form. Data represented in the form of rows and columns (two dimensional table).

Logical & Physical Database Structure


LOGICAL DATABASE STRUCTURE A database can be viewed as consisting of Entities. An entity is an object about which we are storing data. Every entity has attributes. e.g. Employee is an entity which has attributes like, emp-code, emp-name,emp-dept etc. There exists relationship between different entities. We can represent the relationship between our entities using an entity-relationship (E-R) diagram as below.
9

ER-Diagram
SALARY TEAM

PLAYER

GAME

BONUS

10

IDMS Schema or Bachman Diagram


In IDMS, entities are implemented using Record types and relationships are implemented using Set types. IDMS does not allow direct implementation of many-to-many relationship.

11

Bachman Diagram

12

PHYSICAL DATABASE STRUCTURE


Database Area, Page and File IDMS database is divided into one or more areas. An area is defined as the major named subdivision of addressable storage in database. An area is further subdivided into pages. Page is a smallest unit of data transfer between main memory and hard disk.
13

Continue ..
Record types are assigned to areas by designer. Areas are mapped to files.
Many or all areas can be mapped into one file if all areas have the same page size. Each area can be mapped into a different file. One area can be mapped into several files.

14

AREAS and FILES MAPPING


Area Logical Database Page

File Physical Database

Block
15

Advantages Of using Multiple Areas


Processing efficiency Records those are accessed together during most of the processing can be grouped together into same area for efficiency. Security One can restrict access to certain record types. e.g. salary-area can be restricted to only finance department.
16

Continue
Database recovery and backup Database can be initialized, reorganized and backed up on area-by-area basis. Backup of most updated areas can be made more frequent than other areas. Concurrent updating A program can request exclusive use of an area and prevent other programs from accessing it concurrently.
17

Concept Of DB-KEY
Each Record occurrence stored in the database is assigned an unique numeric identifier, called Database Key (db-key). A records db-key consists of a 32-bit field that contains a 23-bit page number and an 8-bit line number. The page number identifies the page in which the record is stored and the line number identifies location of the record occurrence within the page.

18

Continue..
The format of db-key is as below:

Sign Bit

Database Page Number

Line Number

1-bit (Not Used)

23-bits

8-bits

19

Record type is like a template. It describes the format of all occurrences of a given record type stored in database. Record occurrence represents the smallest directly addressable unit of data. It consists of fixed or variable number of characters that are subdivided into units called Data Elements.

RECORD TYPE v/s RECORD OCCURRENCE

20

Continue
Employee Record Type .

Emp-code PIC 9(4)

Emp-name PIC X(30)

Sex PIC X

Emp-dept PIC X(10)

Employee Record Occurrences ..... 1000 ABC M TECH

1500

XYZ

SALES

21

Schema is the logical definition of a database. A schema is a complete database description (all records types & record elements, set types, files and areas). There is ONE and ONLY ONE schema for a given database. A subschema defines a subset of the schema. A subschema is similar to a view in a relational database.
22

Schema and Subschema

UNIT 2
Record Characteristics

Objectives
Participants will be able to learn The characteristics that apply to record types : Record Name Record Identifier Storage Mode Record Length Location Mode Duplicates Option Area Name

24

Record Name
Each record type must be assigned a 1 to 16 character name that identifies the record type. The name must begin with an alphabetic character. The application program must reference the records name in DML (Data Manipulation Language).

25

Record Identifier
It is a number that serves as in internal identifier for the record type. It is in the range 100 through 9999. Each record type must be assigned an unique record identifier within the installation. DBAs assign this number to each record type. Application programs do not refer to record type using this number.

26

Storage Mode
It indicates whether record occurrences of the record type are fixed or variable length and whether they are stored in compressed format. Allowable codes are:

F (fixed length) V (variable length) C (compressed)

27

Record Length

It is expressed in BYTES. It is the actual data length for fixed-length record or the maximum data length for variable-length record.

28

Location Mode
It defines the way record occurrences are stored in the database. Allowable location modes are:
CALC VIA DIRECT

29

Calc Mode
In CALC mode, a particular data element within the record is declared as the CALC-key. At the time of storing the record in the database, IDMS system uses value of the data element to calculate the page number for storing a record. Records stored with a CALC mode can be retrieved from disk in a single access. For retrieving the record (stored with CALC location mode), appropriate value for the data element is moved to the storage area in the application program and then DML retrieval function is executed.

30

Via Mode

Records stored with VIA location mode are stored near another database record. This mode is generally used for storing member records on the same page containing owner record or on a page near their owner record. This mode tends to reduce disk accesses needed to retrieve all the records of a set occurrence. CALC retrieval is not possible in case of records stored with VIA location mode. Generally the owner record is assigned CALC location mode for easy access of member records.

31

Direct Mode

In DIRECT location mode, application program explicitly specifies the page into which the record should be stored. To retrieve this record, programmer must specify its database address, i.e db-key of the record. This mode is less often used than CALC and VIA mode.

32

Duplicates Option

It is specified only for record types that are stored using CALC location mode. It specifies whether records with duplicate CALCkey values are allowed and if so, how would they be stored in the database. Possible codes are : DN (Duplicates Not Allowed) Record occurrences with duplicate CALC-key value will not be accepted. IDMS will give an error if application program tries to store a record with duplicate CALC-key.

33

Continue
DF (Duplicates First) IDMS will store the record with duplicate CALC-key value Before any record in the database that has matching CALC-key value. When CALC retrieval is made using CALC-key value, newly stored record will be retrieved first. DL (Duplicates Last) IDMS will store the record with duplicate CALC-key value After any record in the database that has matching CALC-key value. When CALC retrieval is made using CALC-key value, newly stored record will be retrieved last.

34

Area Name

It is the name of the area into which all record occurrences of the record type are to be stored. e.g. CUST-AREA, SALARY-AREA, SALES-AREA etc.
Example : Data Structure Diagram (DSD) for Employee Record Type

EMPLOYEE 1000
F EMP-CODE HR-AREA
35

150

CALC DN

UNIT 3
Set Characteristics

Objectives
Participants will be able to learn the characteristics that apply to Sets: Set Name Linkage option Membership Option Order option Duplicates Option Indexed Sets

37

Set ???
WHAT IS A SET ? A Set consists of an OWNER record type and one or more MEMBER record types. SET OCCURRENCE ? A Set Occurrence consists of one occurrence of owner record type and any number of member record occurrences.

38

Set Characteristics
Set Name A unique name must be given to each set type in the database. The name can be maximum of 16 characters. The set name must be referenced whenever an application program accesses records using that set relationship. Usually it will be owner record name followed by member record name e.g. CUST-ORDER.

39

Linkage Options
Linkage Options It indicates the types of pointers that are used to implement the set. Pointers provide flexibility in accessing records in a set occurrence. Pointers are stored in the prefix part of the database record occurrences. Available options are: N (NEXT pointer) Each record in the set contains a pointer to the next record occurrence. This option allows to access member records only in the forward direction. Next pointer is mandatory for all sets. All other pointers are optional.

40

Linkage Options (cont)


NP (NEXT and PRIOR pointer) With this, in addition to Next pointer, each record contains pointer to prior record occurrence in the set. This allows us to access member records in both forward and backward direction. NO (NEXT and OWNER pointer) With this, in addition to Next pointer, each record contains pointer to owner record occurrence in the set. This allows us to access the owner record directly from any member record occurrence.

41

Linkage Options (cont)


NPO (NEXT, PRIOR and OWNER pointer) Each record in the set contains all three pointers. This option allows to access member records in both forward and backward direction and also allows to access the owner record directly from any member record occurrence.

42

MEMBERSHIP OPTIONS
The Membership options specify how a member record may be connected to or disconnected from a set occurrence. The option is defined in two parts. First part is a Disconnect Option, indicating the way a record is disconnected from a set. Second part is the Connect Option, indicating how a record is connected to a set.

43

It specifies whether a member record can be later disconnected from a set once its membership has been established. Possible values are: M (Mandatory) The record cannot be disconnected from a set unless that record is deleted (erased) from the database using the ERASE command. O (Optional) A record occurrence can be disconnected from a set. The record remains in the database. It can be connected to some other set occurrence. It is optional to use ERASE for such records.

Disconnect option

44

Connect option
It specifies whether or not a member record is automatically connected to a set occurrence when it is added to the database. Possible values are: A (Automatic) Automatic means when a member record is inserted in database, IDMS will automatically connect it to all its owner records (provided currencies have been established for owners). M (Manual) Manual option specifies that after inserting a record, programmer must explicitly connect it to its owner record by issuing CONNECT statement.
45

Combinations for Membership Options


Disconnect Connect

MA MM OA -

Mandatory Automatic Mandatory Manual

Optional

Automatic

OM
46

Optional

Manual

The order option specifies logical order in which member record occurrences are placed within a set occurrence. Options available are: FIRST Each new member record occurrence is placed immediately after the owner record (in the next direction). This option achieves a member record in LIFO.

Order option

LAST Each new member record occurrence is placed immediately before the owner record (in the prior direction). This option achieves a member record in FIFO. Prior pointer is a must to specify this option.

47

NEXT Each new member record occurrence is placed immediately after the member record occurrence that was last accessed (in the next direction). PRIOR Each new member record occurrence is placed immediately before the member record occurrence that was last accessed within the set (in the prior direction). Prior pointer is a must to specify this option.

Order option (Cont)

48

SORTED Each new member record occurrence is placed in ascending or descending sequence, based on the value of designated sortcontrol data element (sort-key) in each record occurrence. When the record is placed into a set, DBMS examines the sort-key value in each member to find the logical position of new member record in the set.

Order option (Cont)

49

This option is useful only in case where set is defined with order option as Sorted. It indicates the action to be taken when a duplicate sort-key value occurs. DN (Duplicates Not Allowed) Record occurrences with duplicate sort-key value will not be stored in the set. IDMS returns an error code if program tries to store such a record. DF (Duplicates First) Record with duplicate sort-key value is stored Before any existing record in the set that has matching sort-key value. Most recently stored duplicate record will be retrieved first.

Duplicates Option

50

DL (Duplicates Last)

Duplicates Option (cont)

The record occurrence with duplicate sort-key value is stored After existing record in the set that has matching sort-key value. Most recently stored duplicate record will be retrieved last.

51

IDMS allows retrieval of records using an index. In conventional sets, member records are chained together by pointers. In an indexed set, DB-key values of member record occurrences are stored in a specified order in one or more index records. Adds flexibility to data retrieval and retrieval is made faster in some cases.

Indexed Sets

52

Indexed sets are useful in cases where:


Records need to be accessed using alternate-key (apart from CALC key). Walking very long sets and when only key values of a member record is required. Member records need to be retrieved randomly using partial key value. Indexed sets can be implemented using two database record types or a single record type and a system defined record type.
53

Indexed Sets(cont)

TEAM-PLAYER

TEAM-GAME

SALARY
2000 F 40 VIA

NPO OM LAST

TEAM 1100 F 80 CALC DN

NPO MM NEXT

PLAYER-SALARY

TEAM-NAME

SALARY-AREA
PLAYER-SALARY NPO OA NEXT

TEAM-AREA

PLAYER 1000 F 70 CALC DN

GAME 1200 F 70 CALC DN

PLAYER-BONUS NPO OA NEXT

PLAYER-NAME

GAME-PLAY-DATE

TEAM-AREA

TEAM-AREA

BONUS 2500 F 25 VIA


PLAYER-POSITION NPO OA NEXT

POSITION 3000 F 50 VIA


GAME-POSITION NPO MA NEXT

PLAYER-BONUS

GAME-POSITION

SALARY-AREA
54

POSITION-AREA

UNIT 4
IDD & DDDL & DDL

Objectives
Participants will be able to have an overview on : IDD DDDL DDL

56

IDD stores meta-data about all the data items in the database (The data values are not stored in IDD). Stores information about users, application programs, files, record, data element, module (date routine, error handling routine) and application systems. IDD is integrated with every software component provided in IDMS like ADSO, OLQ and Report Generator. Each software component accesses IDD to get information about data items and programs.

INTEGRATED DATA DICTIONARY (IDD)

57

DATA DICTIONARY DEFINITION LANGUAGE (DDDL) The data dictionary definition language (DDDL) is used to create,
update or delete entity occurrences in IDD. DDDL provides five verbs to manipulate entities: ADD to add a new entity. MODIFY to change entity description. DELETE to remove an entity. DISPLAY to display an entity description.

PUNCH to copy entity information from IDD to a file.

58

ADD ELEMENT CITY-NAME ELEMENT DESCRIPTION TEAM CITY PICTURE X(20) USAGE DISPLAY. DISPLAY PROGRAM STATSEDIT. DELETE PROGRAM NAME IS STATSEDIT.

Example of DDDL

59

Data Description Language (DDL) is used to define:


SCHEMAS SUBSCHEMAS
DEVICE-MEDIA CONTROL LANGUAGE (DMCL) MODULES

Data Description Language (DDL)

Many aspects of the databases physical structure, such


as disk device assignments and page sizes are described in DMCL module definition.

60

IMPLICIT RECORD LOCKS

It is maintained only for run-units operating under Central Version. When we use usage mode options that allow more than one run-unit to access the same area while updating is taking place, IDMS sets Implicit record locks to prevent same record from being updated simultaneously by two or more run-units.

Continue ..

Record locks are generally maintained for shared and protected update mode and shared retrieval mode. Implicit locks can be either Shared or Exclusive. Implicit Shared lock guarantees that only one run-unit is allowed to update a record while others can retrieve the same record. Implicit Exclusive lock ensures that no other rununit can either update or retrieve the record.

Continue

Implicit shared locks is placed on a record when it is retrieved and Implicit Exclusive lock is placed on a record when it is accessed through a DML update verb. Shared Lock remains in effect till currency changes. Exclusive Lock remains in effect till run-unit ends (Finish) or until Commit is issued.

EXPLICIT RECORD LOCKS


Explicit locking is the most efficient way of placing record locks. It can be set by coding the KEEP statement or by the KEEP clause of the FIND/OBTAIN statement. Explicit lock remain is effect until Finish is executed or Commit is issued.

e.g.

Obtain Keep Calc Employee.


Obtain Keep Exclusive Calc Employee.

First is explicit shared lock and second is explicit exclusive lock.

Continue
Another way of setting explicit locks is to code separate Keep statement after a record is retrieved. e.g. Keep exclusive current.

Keep current within Dept-Employee.


Keep exclusive current within employee-area.

Thank You

Questions ???

You might also like