VSAM: KSDS, ESDS, LDS, RRDS Differences and their Uses

Hadoop+NoSQL+Tough Interview QuestionsThe name VSAM states that it is all about storage and Access method. Read my previous post on VSAM.

KSDS: 

  • Each record has one or more key fields.
  • With key field we can access the data randomly. KSDS provides for both Random and Sequential access
  • IMS uses KSDS datasets extensively.
  • These records can be of Variable in length.
  • It consists of Data component and Index component.
  • KSDS extensively being used for Master records – Inventory, Customer, Employee
  • KSDS is less efficient because of Index overhead

ESDS:

  • These are sequential files.
  • Records are written in sequentially.
  • These datasets extensively being used in IMS, DB2 and CICS
  • These records are in sequence
  • Records can be accessed directly by (RBA)
  • The records in ESDS are often in either Ascending or Descending order
  • It is possible, we can also access records through Alternative Index

RRDS:

  • These records can be accessed by relative record numbers. By Record#1 , Record#2…..etc.
  • It is possible to read records randomly with Index. However,here records are stored in slots. These slots internally read in sequence. So, sequential access is more efficient than access by using Index.
  • Drawback of RRDS is vacant slots. This is main drawback wastage of space, and RRNs are empty.

LDS:

  • These records are byte-stream datasets.
  • Db2 uses extensively this type of datasets.
  • Very rarely used by application programs.
  • The records are written in byte format, so these are called byte-stream datasets.

VSAM Re-usable datasets:

VSAM lets you define an ESDS, a KSDS, or an RRDS as a reusable data set. When a reusable data set is opened for output, VSAM resets the data set so all of its records are ignored and the records of the new data set overwrite the old records.

With a reusable ESDS, for example, VSAM keeps track of the highest relative byte address (RBA) that is used by the data set. Then, when the data set is opened for input or for I/O, VSAM reads all the records sequentially until it reaches the highest RBA. But when the data set is opened for output, VSAM resets the RBA to zero so the old records can be overwritten by the new records. By using a reusable data set, you are able to define a VSAM data set just once and use it repeatedly.

Recommended Links:

Relation Between Alternate Index-Build-Path

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.