idms application programming

Upload: arun-jose

Post on 07-Apr-2018

256 views

Category:

Documents


3 download

TRANSCRIPT

  • 8/4/2019 IDMS Application Programming

    1/67

    IDMS Application Programming

  • 8/4/2019 IDMS Application Programming

    2/67

    Pre-requisites

    MVS and TSO/ISPF subsystem

    JCL & VSAM concepts

    Programming in COBOL

    2

  • 8/4/2019 IDMS Application Programming

    3/67

    Course Contents

    Introduction to DBMS

    Record Characteristics

    Set Characteristics

    IDD and DDDLData Description Language (DDL)

    Data Manipulation Language (DML)

    Recovery & Restart of Database

    Locking Facilities

    33

  • 8/4/2019 IDMS Application Programming

    4/67

    UNIT 1

    Introduction to DBMS

  • 8/4/2019 IDMS Application Programming

    5/67

    Objectives

    Participants will be able to learn:

    Basic concept of DBMS and the types of DBMS systems.

    Logical and Physical Database Structure.

    5

  • 8/4/2019 IDMS Application Programming

    6/67

    DBMS

    Database Management System (DBMS) is a set of computerprograms 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 otherspecialists.

    A DBMS is a system software package that helps the use of

    integrated collection of data records and files known as

    databases.

    6

  • 8/4/2019 IDMS Application Programming

    7/67

    Types OF DBMS

    Hierarchical (e.g. IMS)

    Data records are typically connected withembedded pointers to form a tree structure.

    Each node (except root) can have one andonly one parent.

    Network (e.g. IDMS)

    The database forms a mesh structure Entity-

    Relationship is implemented using Recordtype and Set.

    7

  • 8/4/2019 IDMS Application Programming

    8/67

    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).

    8

  • 8/4/2019 IDMS Application Programming

    9/67

    Logical & Physical Database Structure

    9

    LOGICAL DATABASE STRUCTUREA 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 ourentities using an entity-relationship (E-R)

    diagram as below.

  • 8/4/2019 IDMS Application Programming

    10/67

    ER-Diagram

    10

    SALARY

    BONUS

    TEAM

    PLAYER GAME

  • 8/4/2019 IDMS Application Programming

    11/67

    IDMS Schema or Bachman Diagram

    11

    In IDMS, entities are implemented using Recordtypes and relationships are implemented using

    Set types.

    IDMS does not allow direct implementation ofmany-to-many relationship.

  • 8/4/2019 IDMS Application Programming

    12/67

    Bachman Diagram

    12

  • 8/4/2019 IDMS Application Programming

    13/67

    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

  • 8/4/2019 IDMS Application Programming

    14/67

    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

  • 8/4/2019 IDMS Application Programming

    15/67

    AREAS and FILES MAPPING

    15

    Page

    Area

    Logical Database

    Physical Database

    File

    Block

  • 8/4/2019 IDMS Application Programming

    16/67

    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

  • 8/4/2019 IDMS Application Programming

    17/67

    Continue

    Database recovery and backup

    Database can be initialized, reorganized andbacked up on area-by-area basis. Backup of

    most updated areas can be made morefrequent than other areas.

    Concurrent updating

    A program can request exclusive use of an areaand prevent other programs from accessing itconcurrently.

    17

  • 8/4/2019 IDMS Application Programming

    18/67

    Concept Of DB-KEY

    Each Record occurrence stored in the database isassigned 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

  • 8/4/2019 IDMS Application Programming

    19/67

    Continue..

    The format of db-key is as below:

    19

    8-bits23-bits1-bit

    (Not

    Used)

    Line NumberDatabase Page NumberSign Bit

  • 8/4/2019 IDMS Application Programming

    20/67

    RECORD TYPE v/s RECORD

    OCCURRENCE

    20

    Record type is like a template. It describes theformat of all occurrences of a given record

    type stored in database.

    Record occurrence represents the smallestdirectly addressable unit of data. It consists of

    fixed or variable number of characters that are

    subdivided into units called Data Elements.

  • 8/4/2019 IDMS Application Programming

    21/67

    Continue

    21

    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 F SALES

  • 8/4/2019 IDMS Application Programming

    22/67

    Schema and Subschema

    22

    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.

  • 8/4/2019 IDMS Application Programming

    23/67

    UNIT 2

    Record Characteristics

  • 8/4/2019 IDMS Application Programming

    24/67

    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

  • 8/4/2019 IDMS Application Programming

    25/67

    Record Name

    Each record type must be assigned a 1 to 16character name that identifies the record type.

    The name must begin with an alphabetic

    character. The application program mustreference the records name in DML (Data

    Manipulation Language).

    25

  • 8/4/2019 IDMS Application Programming

    26/67

    Record Identifier

    It is a number that serves as in internal identifierfor 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

  • 8/4/2019 IDMS Application Programming

    27/67

    Storage Mode

    It indicates whether record occurrences of therecord 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

  • 8/4/2019 IDMS Application Programming

    28/67

    Record Length

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

    data length for variable-length record.

    28

  • 8/4/2019 IDMS Application Programming

    29/67

    Location Mode

    It defines the way record occurrences are storedin the database.

    Allowable location modes are: CALC

    VIA

    DIRECT

    29

  • 8/4/2019 IDMS Application Programming

    30/67

    Calc Mode

    In CALC mode, a particular data element within the record isdeclared 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

  • 8/4/2019 IDMS Application Programming

    31/67

    Via Mode

    Records stored with VIA location mode are stored near anotherdatabase 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 CALClocation mode for easy access of member records.

    31

  • 8/4/2019 IDMS Application Programming

    32/67

    Direct Mode

    In DIRECT location mode, application program explicitly specifiesthe 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

  • 8/4/2019 IDMS Application Programming

    33/67

    Duplicates Option

    It is specified only for record types that are stored using CALClocation mode. It specifies whether records with duplicate CALC-

    key 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 tostore a record with duplicate CALC-key.

    33

  • 8/4/2019 IDMS Application Programming

    34/67

    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 recordwill be retrieved last.

    34

  • 8/4/2019 IDMS Application Programming

    35/67

    Area Name

    It is the name of the area into which all record occurrences of therecord type are to be stored. e.g. CUST-AREA, SALARY-AREA,

    SALES-AREA etc.

    35

    EMPLOYEE

    1000 F 150 CALC

    EMP-CODE DN

    HR-AREA

    Example : Data Structure Diagram (DSD) for Employee Record Type

  • 8/4/2019 IDMS Application Programming

    36/67

    UNIT 3

    Set Characteristics

  • 8/4/2019 IDMS Application Programming

    37/67

    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

  • 8/4/2019 IDMS Application Programming

    38/67

    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

  • 8/4/2019 IDMS Application Programming

    39/67

    Set Characteristics

    Set NameA 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 namefollowed by member record name e.g. CUST-ORDER.

    39

  • 8/4/2019 IDMS Application Programming

    40/67

    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. Allother pointers are optional.

    40

  • 8/4/2019 IDMS Application Programming

    41/67

    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

  • 8/4/2019 IDMS Application Programming

    42/67

    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

  • 8/4/2019 IDMS Application Programming

    43/67

    MEMBERSHIP OPTIONS

    The Membership options specify how a member record may beconnected 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 isdisconnected from a set.

    Second part is the Connect Option, indicating how a record is

    connected to a set.

    43

  • 8/4/2019 IDMS Application Programming

    44/67

    Disconnect optionIt specifies whether a member record can be later disconnected

    from a set once its membership has been established. Possiblevalues 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.

    44

  • 8/4/2019 IDMS Application Programming

    45/67

    Connect option

    It specifies whether or not a member record is automaticallyconnected 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, programmermust explicitly connect it to its owner record by issuing CONNECT

    statement.

    45

  • 8/4/2019 IDMS Application Programming

    46/67

    Combinations for Membership OptionsDisconnect Connect

    MA - Mandatory Automatic

    MM - Mandatory Manual

    OA - Optional Automatic

    OM - Optional Manual

    46

  • 8/4/2019 IDMS Application Programming

    47/67

    Order optionThe order option specifies logical order in which member record

    occurrences are placed within a set occurrence. Options availableare:

    FIRST

    Each new member record occurrence is placed immediately after

    the owner record (in the next direction). This option achieves amember record in LIFO.

    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

  • 8/4/2019 IDMS Application Programming

    48/67

    Order option (Cont) NEXT

    Each new member record occurrence is placed immediately afterthe member record occurrence that was last accessed (in the next

    direction).

    PRIOR

    Each new member record occurrence is placed immediatelybefore 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

  • 8/4/2019 IDMS Application Programming

    49/67

    Order option (Cont) SORTED

    Each new member record occurrence is placed in ascending ordescending sequence, based on the value of designated sort-

    control 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 memberrecord in the set.

    49

  • 8/4/2019 IDMS Application Programming

    50/67

    Duplicates OptionThis option is useful only in case where set is defined with order

    option as Sorted. It indicates the action to be taken when aduplicate 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 storesuch 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 recentlystored duplicate record will be retrieved first.

    50

  • 8/4/2019 IDMS Application Programming

    51/67

    Duplicates Option (cont) 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

  • 8/4/2019 IDMS Application Programming

    52/67

    Indexed Sets 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 indexrecords.

    Adds flexibility to data retrieval and retrieval is

    made faster in some cases.

    52

  • 8/4/2019 IDMS Application Programming

    53/67

    Indexed Sets(cont) 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

    TEAM-PLAYERTEAM GAME

  • 8/4/2019 IDMS Application Programming

    54/67

    54

    SALARY

    PLAYER

    BONUS

    TEAM

    POSITION

    GAME

    SALARY-AREA

    SALARY-AREA

    TEAM-AREA

    TEAM-AREA

    TEAM-AREA

    POSITION-AREA

    DN

    DN

    DN

    VIA

    VIA VIA

    CALC CALC

    CALC40

    70

    25 50

    80

    701000

    1100

    1200

    2000

    25003000

    F

    F

    F

    F

    F

    F

    PLAYER-BONUSGAME-POSITION

    PLAYER-NAME

    PLAYER-SALARY

    GAME-PLAY-DATE

    TEAM-NAME

    PLAYER-SALARY

    NPO

    OA

    NEXT

    NPO

    OM

    LAST

    PLAYER-BONUS

    NPO

    OA

    NEXT

    PLAYER-POSITION

    NPO

    OA

    NEXT

    GAME-POSITION

    NPO

    MA

    NEXT

    TEAM-GAME

    NPO

    MM

    NEXT

  • 8/4/2019 IDMS Application Programming

    55/67

    UNIT 4

    IDD & DDDL & DDL

  • 8/4/2019 IDMS Application Programming

    56/67

    Objectives

    Participants will be able to have an overview on :

    IDD

    DDDL

    DDL

    56

  • 8/4/2019 IDMS Application Programming

    57/67

    INTEGRATED DATA DICTIONARY (IDD) 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 andprograms.

    57

    DATA DICTIONARY DEFINITION

  • 8/4/2019 IDMS Application Programming

    58/67

    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

  • 8/4/2019 IDMS Application Programming

    59/67

    Example of DDDLADD ELEMENT CITY-NAME

    ELEMENT DESCRIPTION TEAM CITYPICTURE X(20)

    USAGE DISPLAY.

    DISPLAY PROGRAM STATSEDIT.

    DELETE PROGRAM NAME IS STATSEDIT.

    59

  • 8/4/2019 IDMS Application Programming

    60/67

    Data Description Language (DDL) Data Description Language (DDL) is used to

    define: SCHEMAS

    SUBSCHEMAS

    DEVICE-MEDIA CONTROL LANGUAGE (DMCL) MODULES

    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

  • 8/4/2019 IDMS Application Programming

    61/67

    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 areawhile updating is taking place, IDMS sets

    Implicit record locks to prevent same record

    from being updated simultaneously by two or

    more run-units.

    C ti

  • 8/4/2019 IDMS Application Programming

    62/67

    Continue ..

    Record locks are generally maintained for sharedand protected update mode and shared retrievalmode.

    Implicit locks can be either Shared or Exclusive.

    Implicit Shared lock guarantees that only onerun-unit is allowed to update a record whileothers can retrieve the same record.

    Implicit Exclusive lock ensures that no other run-

    unit can either update or retrieve the record.

  • 8/4/2019 IDMS Application Programming

    63/67

    Implicit shared locks is placed on a recordwhen 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.

    Continue

  • 8/4/2019 IDMS Application Programming

    64/67

    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 exclusivelock.

    EXPLICIT RECORD LOCKS

    C i

  • 8/4/2019 IDMS Application Programming

    65/67

    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.

    Continue

  • 8/4/2019 IDMS Application Programming

    66/67

    Thank You

  • 8/4/2019 IDMS Application Programming

    67/67

    Questions ???