COBOL Indexed Vs Sort top differences you need to know

Indexed file and sorted file both are different concepts. When I asked in an interview many developers confused about it to tell right answer. These quick ideas help you understand well.

Index Vs Sort

Indexed file Vs Sorted file

Indexed file

  • Indexed files use a primary key field to identify the records of an original file in a database. A primary key field is a unique field. An indexed file consists of actual records sorted based on the primary key field value
  • An indexed file also consists of alternate keys, which build the alternate index. Unlike primary keys, the alternate keys in an indexed file do not have actual records.
  • The advantage of primary key field values is that because of the indexing of actual records, you require only one input-output operation to access records in an indexed file

Sorted file

  • Sorting is the arrangement of the records of a file in ascending or descending order based on specific key data items
  • For example, you can sort a file containing employee payroll records by employee identification number in ascending order. You can sort a file on more than one data item. Example ID and Department
  • When you sort a sequential file, its records are stored on the hard disk and you can only access them serially. It is not possible to access all the records of a file simultaneously.

Also Read

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.