Presentation is loading. Please wait.

Presentation is loading. Please wait.

Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store.

Similar presentations


Presentation on theme: "Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store."— Presentation transcript:

1 Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store Large volumes Volatile information Files are stored on secondary storage

2 Files  File categories Serial files Indexed sequential files Relative files

3 Serial Files  Text files  Program files  Report files  Work files  Transaction files  Sequential files  Different record formats possible

4 Characteristics of Serial Files  Records written consecutively  More than one record format  Stored on serial devices or DASDs (Direct Access Storage Devices)  Used for sorting  Can be used in batch mode  Sequential access quicker

5 Suitable Subjects for Serial Files  No direct access requirement  Large volumes of information  Record order unimportant  Different record types  No updating requirement

6 Using Sequential Files  Preparation Source - key to tape, key to disk, optical scanners, voice recognisers Verification on communication and values required May be sorted or merged

7 Using Sequential Files  Prepare the data Copy the file to offline backup Copy the file locally Check fields Merge multiple files Sort

8 Using Sequential Files  Declare the file to the program  To read: Open the file for input to the program Read the first record Check to see if the read failed due to end-of-file While not end-of-file Process the record Read the next record Close the file

9 Indexed Sequential File Characteristics  File management system looks after indexing  Records are accessed directly or sequentially  Each record has one or more key fields  Overuse of indexing is inefficient  Very good multi-user capabilities

10 Indexed Sequential File Ideal Subjects  Medium to large amount of data  Data filed mainly by one key  Regular sequential and direct access  Possible skip sequential access  Low volatility and growth  Low alternate key access requirement

11 Using Indexed Sequential Files  Declaring File and device name Organisation (indexed) Primary key Alternate keys  Creation Writes using keys

12 Retrieval From Indexed Sequential Files  Direct access: Give key value Read, allowing for no record, or lock  Direct and sequential Read next record, allowing for end of file or lock

13 Retrieval From Indexed Sequential Files  Sequential Specify start of range and key Loop to Read next record, allowing for end-of-file and lock Check for end of range or file

14 Updating Indexed Sequential Files  Change non-primary key values Read record directly with lock Change non-primary key values Rewrite record Unlock

15 Updating Indexed Sequential Files  Changing primary key value Read record directly with lock Check for new record viability Copy record details Write new record with lock Delete old record Release locks

16 Deleting From IS Files  Read record with lock  VERIFY that deletion is required  Delete record  Release locks

17 Direct Access or Relative Files  Records can be accessed directly, according to the number of the record within the file  Each record has a key, which is it’s relative address from the start of the file  This is suitable for only a small number of records

18 Direct Access or Relative Files  All key values must be used  Very easy to use (using relative addressing)  Hashing functions can be used (see algorithms course)

19 Using Relative Files  File is declared using file name and storage device  Organisation is relative  An independent variable holds the key  The record format is declared

20 Using Relative Files  The file is opened for input, output or updating  Records can be read, added, amended using direct access  Records can be read sequentially from a pre- set point in the file  The file is closed

21 Using Relative Files  Creation Addressing method must be implemented to position records Insertion of records uses direct access

22 Using Relative Files  Retrieval Sequential access if no hashing Retries may be necessary if hashing being used Retries may be necessary if multi-user file, because of locking  Updates Direct access mode Deletion causes gaps Record / file locking must be implemented

23 Relative Files Select Expend-file assign "Expend.dat" organization is relative access mode is random relative key is month-number. Working-Storage Section. 01 month-number pic 99.

24 Procedure division Open I-O Expend-file. Move L-month-in to month-number. Read Expend-file invalid key display "month not found for " L-month-in not invalid key move fields to record rewrite expend-record invalid key display "Error rewriting... " end-rewrite end-read close expend-file.


Download ppt "Files  File organisation and usage A record is a group of logically related fields A file is a group of logically related records Files are used to store."

Similar presentations


Ads by Google