Advanced Data Representation and File Organisation: Question 2
Syllabus 13.2
A vehicle repair garage keeps three separate computer files.
-
JobLog: every time a mechanic finishes a repair job, a new record is appended to the end of this file. At the end of each day, the whole file is read from start to finish to print a worksheet of everything completed that day. Individual jobs are never looked up on their own, and the file is never searched for one specific job.
-
CustomerMaster: this file holds one record per customer, held in order of the key field
CustomerID. Once a month, the file is processed from the first record to the last, inCustomerIDorder, to update every customer's loyalty points. Occasionally, when a customer phones in, the receptionist needs to bring up that one customer's record straight away. -
PartsStock: the till system must fetch a single spare part's record immediately by its
PartCodethe moment a part is scanned, without reading through any other records first.
(a) State which file organisation is most suitable for JobLog, and justify your choice. [2]
(b) State which file organisation is most suitable for CustomerMaster, and describe the file access method(s) this organisation supports that let the garage meet both of the stated needs for this file. [3]
(c) State which file organisation is most suitable for PartsStock, and explain how the storage location of an individual record is determined in this organisation. [3]
Show worked solution Hide worked solution
Worked solution
Part (a): JobLog
JobLog has two defining features: new records are only ever appended to the end, and the
whole file is read straight through from start to finish, never searched for one particular
job. There is no key field being used to keep the file in any particular order.
This is exactly what serial file organisation provides: records are stored one after another in the order they are written, with no attempt to order them by a key. The matching access method. Reading every record in turn from the beginning, is called sequential access.
[2 marks]: [1] for stating serial file organisation, [1] for a justification that connects “always appended to the end” and/or “always read straight through” to that choice.
Part (b): CustomerMaster
CustomerMaster has records held in order of the key field CustomerID, and needs to support
two different needs: a full pass through every record in key order (the monthly update), and
an immediate single-record lookup (the receptionist’s phone call).
Sequential file organisation. Where records are physically stored in ascending order of the key field, is the appropriate choice, because unlike a random file it preserves a meaningful overall order, and unlike a serial file that order is based on the key rather than arrival time.
Crucially, a sequential file supports both of the file access methods the garage needs:
- Sequential access: reading through the file from the first record to the last, in
CustomerIDorder. Used for the monthly loyalty-points update, which must touch every record. - Direct access: locating one specific customer’s record immediately, for example using an
index built on
CustomerIDthat maps a key value straight to its position in the file, used for the receptionist’s immediate lookup, without reading through every preceding record.
[3 marks]: [1] for stating sequential file organisation, [1] for identifying that it supports sequential access (linking this to the monthly update), [1] for identifying that it also supports direct access (linking this to the immediate phone lookup).
Part (c): PartsStock
PartsStock needs a single record fetched immediately, by its key (PartCode), with no
other records read at all. Neither serial file organisation (which only supports reading from the
start) nor sequential file organisation (which, even with direct access, still relies on an
ordered structure or index built up over the whole file) is as directly suited to this as:
Random file organisation, which supports direct access exclusively: the storage location
of a record is calculated straight from its key field using a hashing algorithm. The hashing
algorithm takes PartCode as input and produces a value that identifies exactly where that
record is stored (e.g. which record or block number in the file). The till system can then SEEK
straight to that location and read the one record it needs, without processing any other record
in the file.
[3 marks]: [1] for stating random file organisation, [1] for identifying that this gives direct access, [1] for explaining that a hashing algorithm calculates the storage location directly from the key.
Final answers
- (a) Serial file organisation. Records are appended in arrival order and read straight through.
- (b) Sequential file organisation (ordered by
CustomerID), supports both sequential access (the monthly update) and direct access (the receptionist’s immediate lookup). - (c) Random file organisation, a hashing algorithm calculates a record’s storage location
directly from its key (
PartCode), giving immediate direct access.