File Organization & Access PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides an overview of file organization and access methods, including serial, sequential, direct, and indexed sequential organization. It details how different methods are used in different situations and explains the pros and cons of each. The summary covers data structures and information processing, and is a good starting point for learning these concepts.
Full Transcript
INFORMATION PROCESSING File Organization & Access File Organization & Access File Organization The way in which files are arranged in storage File Access The way in which files are retrieved from storage Types of Files Master File A master file is a permanent fil...
INFORMATION PROCESSING File Organization & Access File Organization & Access File Organization The way in which files are arranged in storage File Access The way in which files are retrieved from storage Types of Files Master File A master file is a permanent file which is kept up-to-date and stores the main information, summary data and key fields in the data. The master file contains two types of data: 🢝 Permanent data, such as employee personal data, payroll data employee status and job title 🢝 Less permanent data, which is updated on a regular basis, such as hours worked and taxes deducted. Types of Files Transaction File A transaction file is a temporary file which is used to update the master file after a certain time (at the end of each day or week, for example). The transaction file updates the master file. The records in the transaction file are used to perform three important operations: 🢝 Add: put a new record into the master file 🢝 Update: change the contents of a record or a field that already exists. 🢝 Delete: remove a record from the master file. Types of Files Transaction Log or Change File Transaction log keeps a record of changes to the transaction file. This is important, as many businesses need to record the history of what transactions have taken place and not just the latest one. Updating a Master File with a Transaction File There are two input files, the old master file or grandfather file, and the transaction file. There is one output file called the new master file. Types of File Organization Serial File Organization (Unordered) Sequential File Organization (Ordered) Direct Access Organization Serial File Organization The records are arranged one after another, in the order in which they were added. That is, they have not been sorted into any particular order. Examples of serial files (also called unordered files) include unsorted invoices for customers for the day and a typical shopping list. Record M Record M Record H Record H Record B Record B Record N Record N Record A Record A Record K Record K Record G Record G Record C New records are added at the end of the same file Sequential File Organization The records are stored in sorted order on one or more key fields. Examples of sequential files include invoices for customers sorted on customer number, and class registers sorted on last name. Record A Record A Record B Record B Record C Record G Record G Record H Record H Record K Record K Record M Record M Record N Record N To add new records, a copy of the file is made and the files are rewritten placing the new file into its position. Deleting Records from Serial & Sequential File Organization With both types of files the only way to delete records is to create a new file which omits the records marked for deletion. To delete a record in a serial file: 1. Compare each record with a key value of the record to be deleted (since the transaction file is not sorted). 2. If it is not the record to be deleted, then write that record to the new file. 3. When the record to be deleted is encountered it is not written to the new file. 4. Finally, all the remaining records are written to the new file. To delete a record in a sequential file: 5. All the records with a key value less than the record to be deleted are written to the new file. 6. When the record to be deleted is encountered it is not written to the new file. 7. Finally, all of the remaining records are written to the new file. Deleting from Serial Delete record N Record M Record M Record H Record H Record B Record B Record N Record A Record A Record K Record K Record G Record G Deleting from Sequential Delete record K Record A Record A Record B Record B Record G Record G Record H Record H Record K Record M Record M Record N Record N Direct Access File Organization The records in direct access file are not sorted in ascending and descending order, but are stored in random order. This is done using a mathematical formula to select a storage location for each record. Once the record is stored it is assigned a key which is used to access it randomly. Files Stored using Direct Access 1 Record 01 2 Record 02 3 Record 03 4 Record 04 5 Free 6 Free 7 Record 07 … 220 Record 220 221 Record 221 222 Free 223 Record 223 Indexed Sequential File Organization An indexed file organization is a mix of sequential and direct file organization of records which uses a key to store and retrieve files to speed access. The key indicates the section in storage where the record is stored and within each section the records are stored in sequential order. Index/Key Highest Records 1 5 2 8 3 14 4 20 If record 6 needs to be retrieved, which index should be accessed directly? Ans: Index 2 If record 3 needs to be retrieved, which index should be accessed directly? Ans: Index 1 Types of Access Methods Sequential Access Searches through records, starting with the first record in the file, until the desired record is found. This access method is used by Serial and Sequential File Organization. It is also used partially by Indexed Sequential File Organization. Random Access Searches for records by going directly to the location of the desired record to retrieve it. This access method is used by Direct Access File Organization and partially by Indexed Sequential File Organization.