UNIHIVE

Study Hub UNIPORT CSC 282

CSC 282 · Database Programming

File organisation and access methods

Serial, sequential, indexed sequential and direct (random) files, and how each is read and updated.

Our notes

2 min read

Organisation and access

Organisation is how records are arranged on storage; access is how a program reaches them.

Serial files

Records in the order they arrived, not sorted. Used for transaction files and logs. To find one record, read from the start: on average n/2 reads.

Sequential files

Records sorted on a key (e.g. MatricNo). Good for batch jobs that process most records (printing all results, payroll).

  • Updating: read the old master and the sorted transaction file together and write a new master (the "father-son" method). The old master and transactions are the backup ("grandfather, father, son" generations).
  • Slow for answering one enquiry.

Indexed sequential files

Records sorted by key plus an index that gives the location of blocks of keys. You can process them in order (batch) or use the index to jump near a record (enquiry). Overflow areas hold insertions until the file is reorganised.

Direct (random / relative) files

The key is turned into an address, so a record is reached in about one read.

  • Relative addressing: record number = position (fixed-length records).
  • Hashing: address = h(key), for example the remainder after dividing by the number of slots.

  Example: 101 slots, key 23045: 23045 mod 101 = 17 (because 101 × 228 = 23028, and 23045 − 23028 = 17). Store the record in slot 17.

  • Collisions (two keys, same address) are handled by putting the record in the next free slot or in an overflow chain.

Direct files suit online systems: an ATM must find one account fast.

Comparing them

SerialSequentialIndexed sequentialDirect
Orderednoyesyesno
Find one recordslowslowfastfastest
Process all in orderyes (unsorted)bestgoodpoor
Typical uselogs, transactionspayroll masterstudent recordsbank accounts

Hit rate

Hit rate = records used in a run ÷ records in the file. High hit rate (payroll, 100%) favours sequential; low hit rate (an enquiry about one student) favours indexed or direct access.

Exams usually ask

  • Describe each organisation with its advantages and uses.
  • Compute a hash address and explain collisions.
  • Explain the father-son update and hit rate.

Common mistake

Calling a sequential file "random" because it is on disk. Organisation is about the arrangement and access method, not the device.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 282 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.