CSC 282 · Database Programming
Our notes
2 min readOrganisation 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
| Serial | Sequential | Indexed sequential | Direct | |
|---|---|---|---|---|
| Ordered | no | yes | yes | no |
| Find one record | slow | slow | fast | fastest |
| Process all in order | yes (unsorted) | best | good | poor |
| Typical use | logs, transactions | payroll master | student records | bank 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
-
Indexed file
(opens en.wikipedia.org in a new tab)
Wikipedia, Indexed file, CC BY-SA 4.0 · licence
-
Sequential access
(opens en.wikipedia.org in a new tab)
Wikipedia, Sequential access, CC BY-SA 4.0 · licence
-
ISAM
(opens en.wikipedia.org in a new tab)
Wikipedia, ISAM, CC BY-SA 4.0 · licence
-
NOUN CIT 304: Data Management
NOUN course book (PDF, about 6.9 MB: best on Wi-Fi). Files, databases, the relational model and SQL.
(opens nou.edu.ng in a new tab)
-
NOUN CIT 213: Elementary Data Processing
NOUN course book (PDF, about 0.9 MB). Fields, records, files and processing data.
(opens nou.edu.ng in a new tab)
Watch
-
Best pick File Organizations Explained: Sequential, Indexed & Hashed Methods 💾
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
DBMS - Index Sequential Access Method (ISAM)
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
DSA 52 : Comparison's of Sequential, Index Sequential & Direct Access File Organization
5 min · ≈ 23 MB · about ₦13
(opens youtube.com in a new tab)
-
File Organization Method Index Sequential File Organization
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
DBMS: Lecture #6 on Hash, B+ and Cluster File Organization, Indexed Sequential Access Method
33 min · ≈ 149 MB · about ₦84
(opens youtube.com in a new tab)
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.