VSAM Alternate Indexes Department of Computer Science Northern Illinois University August 2005.

Slides:



Advertisements
Similar presentations
DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
Advertisements

Stephen Linkin Houston Community College 5-Apr-07 © Mike Murach & Associates, HCC, IBM 1 Using AMS (Access Method Services)
CpSc 3220 File and Database Processing Lecture 17 Indexed Files.
Introduction to Database Systems1 Records and Files Storage Technology: Topic 3.
Comp 335 File Structures Indexes. The Search for Information When searching for information, the information desired is usually associated with a key.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
Processing with VSAM Files Please use speaker notes for additional information!
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
MVS/ESA Fundamentals of VSAM © Copyright IBM Corp., 2000, All rights reserved.
1 Lecture 8: Data structures for databases II Jose M. Peña
Managing data Resources: An information system provides users with timely, accurate, and relevant information. The information is stored in computer files.
Introduction of z/OS Basics © 2006 IBM Corporation Chapter 5: Working with data sets.
1 Lecture 20: Indexes Friday, February 25, Outline Representing data elements (12) Index structures (13.1, 13.2) B-trees (13.3)
1 Indexing Structures for Files. 2 Basic Concepts  Indexing mechanisms used to speed up access to desired data without having to scan entire.
Chapter 5: Working with data sets
Homework #3 Due Thursday, April 17 Problems: –Chapter 11: 11.6, –Chapter 12: 12.1, 12.2, 12.3, 12.4, 12.5, 12.7.
Structured COBOL Programming, Stern & Stern, 9th Edition
Virtual Storage Access Method (VSAM)
VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services.
15-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Indexing. Goals: Store large files Support multiple search keys Support efficient insert, delete, and range queries.
Chapter 15 Relative Files.  File organization that converts key field to actual disk address to find location of record No need to look up disk address.
File Organization Techniques
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
File Processing - Indexing MVNC1 Indexing Jim Skon.
10/16/ ER/CORP/CRS/OS02/003-4 JCL DAY 4. 10/16/ ER/CORP/CRS/OS02/003-4 VSAM DATASETS (virtual storage access method) These are the logical.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Indexing Structures for Files by Pinar Senkul resources: mostly froom Elmasri, Navathe and.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Indexed and Relative File Processing
Introduction to the new mainframe © Copyright IBM Corp., All rights reserved. Chapter 4: Working with data sets.
JCL Day 3. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0 Agenda for Day 3  VSAM data sets  Definition & Types 
Indexing and hashing Azita Keshmiri CS 157B. Basic concept An index for a file in a database system works the same way as the index in text book. For.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Appendix C File Organization & Storage Structure.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Session 1 Module 1: Introduction to Data Integrity
Index in Database Unit 12 Index in Database 大量資料存取方法之研究 Approaches to Access/Store Large Data 楊維邦 博士 國立東華大學 資訊管理系教授.
2/20: Ch. 6 Data Management What is data? How is it stored? –Traditional management storage techniques; problems –DBMS.
Spring 2004 ECE569 Lecture 05.1 ECE 569 Database System Engineering Spring 2004 Yanyong Zhang
1 Copyright © 2011 Tata Consultancy Services Limited Virtual Access Storage Method (VSAM) and Numeric Intrinsic Functions (NUMVAL and NUMVAL-C) LG - TMF148.
VSAM ESDS and RRDS Department of Computer Science Northern Illinois University September 2005 Some of the illustrations are from VSAM: Access Method Services.
VSAM KSDS Structure and Processing Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Topics Covered: File Components of file Components of file Terms used Terms used Types of business file Types of business file Operations on file Operations.
Chapter 11 Indexing And Hashing (1) Yonsei University 1 st Semester, 2016 Sanghyun Park.
Ver 1.0/ 3 rd Sep 2001 Classification : InternalProprietary & Confidential VSAM.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Lecture : chapter 9 and 10 file system 1. File Concept A file is a collection of related information defined by its creator. Contiguous logical address.
CS522 Advanced database Systems
Indexing Goals: Store large files Support multiple search keys
Indexing and hashing.
CS522 Advanced database Systems
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
File organization and Indexing
Chapter 11: Indexing and Hashing
Lecture 12 Lecture 12: Indexing.
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
Indexing and Hashing Basic Concepts Ordered Indices
Programming in COBOL-85 For IBM Mainframe System 390
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Database Management System
File Organization.
Overview of VSAM and Defining a Cluster
Chapter 11: Indexing and Hashing
Advance Database System
Unit 12 Index in Database 大量資料存取方法之研究 Approaches to Access/Store Large Data 楊維邦 博士 國立東華大學 資訊管理系教授.
Presentation transcript:

VSAM Alternate Indexes Department of Computer Science Northern Illinois University August 2005

2 Introduction to Alternate Indexes Alternate Indexes (AIX) –Used in KSDS –similar to prime index but indexes on values of some field other than the prime key –can provide an additional way of retrieving the data in a KSDS

3 Introduction to Alternate Indexes Alternate Indexes Example –Student Information primary key:Student-ID alternate index:Student-Name alternate index:Student-Major

4 Introduction to Alternate Indexes Records –are maintained in logical sequence based upon the primary key values via the prime index –are also maintained in logical sequence based upon values of alternate key via additional indexes called alternate indexes

5 Introduction to Alternate Indexes Alternate indexes are created using the DEFINE command in IDCAMS

6 KSDS Base Cluster

7 KSDS Alternate Index

8 Alternate Index Component –Each pointer record contains the primary key value pointer into AIX data component

9 Processing via KSDS Alternate Index Program passes alternate key value to VSAM VSAM proceeds: –searches the index component index to locate the appropriate CI in the alternate index data component

10 Processing via KSDS Alternate Index VSAM proceeds: –reads in the CI from the AIX data component and locates the record that corresponds to the supplied alternate key value this record contains the primary key value of the desired base cluster record –the primary key value just obtained is used to search the primary index as normal

11 Processing via KSDS Alternate Index VSAM proceeds: –the CI is read from the base cluster and the desired record is extracted from it and passed to the application program VSAM performs 2 separate index searches to locate the desired record –first the AIX –second the primary index

12 ESDS Alternate Index ESDS clusters can also be referenced by alternate indexes –Note: RRDS cannot have AIX Structure is similar to that of the KSDS AIX

13 ESDS Alternate Index

14 ESDS Alternate Index VSAM: –searches the index component of the AIX to locate the appropriate CI in the AIX data component –reads in the CI and locates the particular record in the data component that corresponds to the supplied alternate key value this record contains a direct RBA pointer to the desired record in the data component of ESDS base cluster

15 ESDS Alternate Index VSAM: –the CI that contains the desired record is read from the data component of the ESDS is extracted from it based on the RBA value obtained from the AIX

16 Paths and AIX Path –combination of an AIX and the base cluster –has separate set of attributes defined separately from attributes of AIX or base cluster –use DEFINE PATH to create a path –define both base cluster and AIX first

17 Paths and AIX

18 Paths and AIX If an application program refers to base cluster itself –AIX is not used If an application program refers to an AIX itself –records are retrieved from the data component of the AIX –base cluster is not referenced

19 Paths and AIX If an application program wants to access records from a base cluster via an AIX –use a path The program supplies an AIX key value and VSAM searches the AIX to find the corresponding AIX / pointer pair A path must be defined for each AIX –actual DEFINE covered later

20 Nonunique Alternate Key Values In KSDS –primary key must have unique values –when an insertion of a duplicate key value is attempted an invalid key is issued AIX may be either –unique or –nonunique

21 Nonunique Alternate Key Values If AIX is defined as unique, VSAM does not allow duplicate AIX key values If AIX is defined as nonunique VSAM allows records to be loaded and inserted that have the same value in the AIX field

22 Nonunique Alternate Key Values In AIX –there is one record in the data component for each unique AIX key value –has multiple pointer to associated records in the base cluster

23 Nonunique Alternate Key Values

24 Upgrade in AIX When updates to base cluster - AIX may need updating VSAM can be directed to perform all AIX updates automatically Specify UPGRADE option in DEFINE of AIX All AIX of a cluster with upgrade option are known as the base cluster’s upgrade set

25 Upgrade in AIX Upgrade Set –when base cluster is updated, the corresponding updates are applied to all AIXs in the upgrade set Application program has to update any AIXs not in the upgrade set

26 Defining a KSDS Alternate Index Using IDCAMS –DEFINE ALTERNATEINDEX creates a catalog entry for the alternate index allocates space for the AIX associate the AIX with a base cluster

27 DEFINE ALTERNATEINDEX (- NAME (znumber.aixname)- RELATE (zumber.KSDSname)- VOLUMES(ACA301)- RECORDSIZE(avgsize maxsize)- KEYS(length displacement)- TRACKS(1 1) ) Defining a KSDS Alternate Index

28 Calculating RECORDSIZE Calculating Maximum RECORDSIZE –RecordSize = a + b + (n * c) where –a = 5(the control bytes in a CI) –b = alternate key length –c = primary key length –n = 1 OR –n =estimated maximum number of primary keys associated with one AIX value

29 Calculating RECORDSIZE Calculating Average RECORDSIZE –RecordSize = a + b + (n * c) where –a = 5(the control bytes in a CI) –b = alternate key length –c = primary key length –n = 1 OR –n =estimated average number of primary keys associated with one AIX value

30 Defining a Path for an AIX Using IDCAMS –DEFINE PATH gives name to a path specifies the name of the alternate index it references base cluster is not specified because the AIX definition specifies the name of the base cluster

31 Defining a Path for an AIX DEFINE PATH ( - NAME (znumber.pathname)- PATHENTRY(znumber.aixname) )

32 Building an AIX Using IDCAMS –BLDINDEX loads the alternate index AMS –reads the base cluster sequentially and constructs alternate key/pointer pairs for each record –sorts the alternate key/pointer pairs into ascending alternate key sequence –uses the sorted alternate key/pointer pairs to load records into the data component of the AIX

33 Defining a KSDS Alternate Index Go over page 41 of course notes showing –DEFINE ALTERNATEINDEX –DEFINE PATH –BLDINDEX

34 Processing KSDS in COBOL Using AIX A KSDS with an AIX can be processed –sequentially –randomly –dynamically

35 JCL for Using AIX Need to specify –KSDS data set //ddname DD DSN=…. –AIX date set(s) //ddname1 DD DSN=…. //ddname2 DD DSN=…. …. //ddnamen DD DSN=….

36 JCL for Using AIX Example JCL //GO.MASTER DD DSN=znumber.KSDS,DISP=SHR //GO.MASTER1 DD DSN=zumber.PATH2,DISP=SHR //GO.MASTER2 DD DSN=znumber.PATH2,DISP=SHR //….

37 File-Control for AIX in KSDS File-Control. SELECT file-name ASSIGN to DA-ddname ORGANIZATION IS INDEXED ACCESS MODE IS [SEQUENTIAL | RANDOM | DYNAMIC RECORD KEY IS recordKeyName ALTERNATE RECORD KEY IS aixKey1 [WITH DUPLICATES] ALTERNATE RECORD KEY IS aixKey2 [WITH DUPLICATES] …. ALTERNATE RECORD KEY IS aixKeyn [WITH DUPLICATES] FILE STATUS IS statusCodeField.

38 File-Control for AIX in KSDS ALTERNATE RECORD KEY IS aixKey1 [WITH DUPLICATES] –specifies the name of an alternate key field for the KSDS file –one per AIX that will be used in the program in same order as specified in the IDCAMS (not all have to be coded all the time) –WITH DUPLICATES specifies that the AIX key value is non-unique

39 AIX Sequential Processing Specify key to use in the START statement MOVE spaces/zeros TO aixKey1. START ksdsFileName KEY NOT < aixKey1. –Where aixKey1 is the name of the alternate key as specified in ALTERNATE RECORD KEY IS aixKey1 Subsequent READ statements retrieve the records in alternate key sequence

40 AIX Sequential Processing When AIX key has duplicate values the status code contains values –00 - last record with AIX key value has been successfully read –02 - a record has been read successfully and there are more with this AIX key value –23 - no record found with the specified AIX key value

41 AIX Sequential Processing PROCEDURE DIVISION code for processing sequential reads of duplicate AIX key values –Read page 45 in class notes

42 AIX Random Processing Only the READ and REWRITE statements are coded differently –READ statement change READ ksds-fileName RECORD INTO identifier KEY IS aixKey1 INVALID KEY imperative-statement. –To use AIX key, the KEY IS clause must be coded

43 AIX Random Processing Only the READ and REWRITE statements are coded differently –REWRITE statement change the AIX key value can be changed via the rewrite Note: primary key value cannot be changed this way - thus the change