IDMS Application Programming
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).
ER-Diagram
SALARY TEAM
PLAYER
GAME
BONUS
10
11
Bachman Diagram
12
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
Block
15
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
Line Number
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.
20
Continue
Employee Record Type .
Sex PIC X
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
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:
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
41
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
MA MM OA -
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.
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.
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)
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(cont)
TEAM-PLAYER
TEAM-GAME
SALARY
2000 F 40 VIA
NPO OM LAST
NPO MM NEXT
PLAYER-SALARY
TEAM-NAME
SALARY-AREA
PLAYER-SALARY NPO OA NEXT
TEAM-AREA
PLAYER-NAME
GAME-PLAY-DATE
TEAM-AREA
TEAM-AREA
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.
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.
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
60
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.
e.g.
Continue
Another way of setting explicit locks is to code separate Keep statement after a record is retrieved. e.g. Keep exclusive current.
Thank You
Questions ???