File Organizations and Types
  1. Sequential - begin processing at beginning until the very end. Searching the file for a particular record results in the exhaustive read of a file. Large files become extremely burdensome and time consuming. Impractical in a online environment.
  2. Direct Access - requires the use of a key to retrieve a record.
    1. Relative file Processing - records are directly addressed using RELATIVE KEYS. The key allows for direct location of a record.
      1. Records are retrieved by a record number, the record number is the location number in the file. The keys are a serial set of locations, 1 to N, each record is accessed according tp its location number. In order for this to work, the record number must be of some significance to the corresponding record in order for it to be useful. If you want to update inventory item number 250 from your inventory file, then the inventory item number must match the record number. Any problems with this?
      2. If there is no direct relationship between the record number, the RELATIVE KEY, and the record then you must keep track of the relationship between them. One way might be to use a table where RECORD NUMBER N is associated with INVENTORY ITEM NUMBER E6-445, row 6 of electronics bin number 45.
    2. Indirect Addressed
      1. Records are retrieved by their location which is computed using an algorithm to convert to data value to a record location. Basically you find the number records per track on a disk, calculate the total number of tracks needed for you file, using the closest prime number to the total number of tracks needed. Sometimes called Hashing. Here's an example.
        1. Assume an employee database of no more than 500 employees. Their id number is PIC 9(3). This would have a maximum of 999 directly addressed records of which 499 are wasted! If we Hash the key with a prime number close to 500 but not over it we will obtain a remainder that is from 0 to 498. If we then add 1 to the remainder we can use this as the relative address. Assume id number 855. 855//499 gives you a remainder of 356. So it's record would be located at 356+1, or 357. As you may have noticed there will be times when the more than 1 key hashes to the same answer. These collisions are names synonyms. Id number 500 and 999 both result in a remainder of 1 yielding relative record 2. So how do I store 2 records in one location? You can't. Your logic has failed and you must seek a new career. Just kidding. One method is to search sequentially until you hit a record that is unused and write the record there. This requires the search process to try a direct read and if failed start searching sequentially until you find it.
    3. Indexed - we will study ISAM, briefly, and VSAM in detail for sequential and indexed processing.
  3. Relational - This organization refers to relational database tables. We will cover basic SQL and the processing of tables as a group of files that are "Magically" linked together by common keys (Foreign Keys). Access from one table can yield to direct access to other tables by field values from the first table



FILE TYPES

File Types are classify by their usage.

  1. Master - primary file for a system
    1. one record per employee, account, student, customer
    2. usually a direct access, or more recently, relational
  2. Transaction - records with new data, changes to existing data
    1. three basic types of transactions with variations: add, change, delete
    2. created from data entry or by a program reading another file.
    3. used to update master file
    4. processed by a file maintenance program
  3. Table
    1. for lookups to get corresponding data values
    2. for data validation
  4. Control - also called control card(s)
    1. one or several records
    2. contains several key data values which determine what a program will do: date, date range, switch, etc.
  5. History - all processed transactions
    1. may contain one year's worth or since implementation of system
    2. new records are appended to file
  6. Journal - before and after images of master file records
    1. records created every time master record is updated
    2. primary use would be to reconstruct the master file
    3. also used for auditing purposes to show master file activity
  7. Backup - copy of a file, especially for master files
    1. usually backups are done at some regular intervals and each file is saved for a period of time
    2. used to restore the master file


COBOL Specifics for Relative Files
		ACCESS IS RANDOM 
		ORGANIZATION IS RELATIVE or SEQUENTIAL or DYNAMIC 
		RELATIVE KEY IS data-field