Organization and Access
The method of organization of a file refers to:
1 The way in which the records are arranged within the file.
2 The method of working out where each record is stored in the file.
There are various different ways of organizing computer files.
The method of access to files refers to the way in which a program reads data from a file or writes data to it.
The different methods of access to files include the following.
SEQUENTIAL ACCESS
Access to a file is sequential when records can only be written to or read from it in order, one after another.
Sequential files can be stored on either a serial access medium (such as magnetic tape) or a direct access medium (such as magnetic disc).
DIRECT ACCESS (ALSO CALLED RANDOM ACCESS)
Access to a file is direct when any record can be accessed without having to access other records first.
Direct access files can only be stored on a direct access medium (such as magnetic disc).
Advantages of direct access over sequential
1 Selected records can be accessed far more quickly from direct access files.
2 Records can be accessed in any chosen order.
3 Records do not have to be put into any particular order before the file is created.
Advantages of sequential access over direct
1 For the user: sequential files can be stored on most media including magnetic tape, paper tape and punched cards as well as magnetic discs.
2 For the programmer: it is usually easier to write programs to handle sequential files.
FACTORS AFFECTING CHOICE OF METHOD OF ACCESS
1 How many records are to be accessed. If records are to be accessed singly or only a few at a time, then sequential files would be inefficient. Direct access should be used.
2 How large the file is. If a file is small, the time delay in searching it is not important therefore a sequential file is acceptable.
3 Whether the application is interactive. Sequential access is often suitable for batch applications. On-line applications such as information retrieval usually need direct access.
4 The type of storage medium being used. If magnetic tape is to be used, then files will have to be sequential.
Examples of uses
1 Sequential access
A payroll application where the main file of employee details is to be stored on tape. Each employee has an employee number which can be used as a key.
The main operations to be done are (see Fig 3):
(a) Weekly pay run- the computer goes through the employees in sequence working out their pay.
(b) Update run-a file of changes is produced in employee number order and the computer goes through this file and the main file in sequence, making changes to the main file .
Note: It does not matter for either of these operations that individual records cannot be accessed quickly. In case (a) the whole file is processed anyway.
2 Direct access
Maintenance records for a lift repair firm. Engineers from the firm service the lifts in buildings and keep records of what they do. The data is stored in a computer file in the order of the dates on which the services take place. An index is held in the computer’s main store which shows where each record is stored. If the computer is given a date it searches the index to find whereabouts the records are for that day and retrieves them directly.
A typical record includes the date, building, name of customer, address, type of contract (3 or 6 months), 11/04/87 SABRE HOTEL MORLEY FOODS BRYANT SQUARE, MOSSTOWN 6
A direct access use of this system is to find out which lifts to service on a particular day. The lifts are on either six-month or three-month contracts. The computer checks only the two dates,6 months and 3 months before that day. It then prints out all the six-month contracts on the first date and the three-month contracts on the second date.
Note: The file has sequential organization but direct access. In fact it can also be accessed sequentially. This facility is used to find all the repair and service calls made to the lifts in a particular building. To do this the computer reads the whole file, a record at a time. It checks the second field in each record for the building in question. Each time the right name appears that record is printed out.