Unit 5 · Lesson 516 minAcademic review pending

Letters, words, sentences — bits, fields, records

A book is built from a fixed hierarchy: letters into words, words into sentences, sentences into chapters. Stored data follows the identical shape.

Choose explanation

After this lesson

You should be able to

  • Name the levels of the data hierarchy from bit to file.
  • Distinguish sequential, direct, and indexed-sequential file organization.
  • Choose the right file organization for a stated access pattern.
01

The same hierarchy, in a book and in a file

A book is letters grouped into words, words into sentences, sentences into paragraphs, paragraphs into chapters. Stored data follows an identical ladder: bits group into bytes, bytes into fields (a single roll number, a single name), fields into records (one student's complete row), and records into a file (the whole class list).

This ladder is not arbitrary — each level exists because programs need to address it separately. You read one field (a name) without reading the whole record, and one record without reading the whole file, exactly as you can quote one sentence without reprinting the whole chapter.

02

Sequential: a cassette tape

A cassette tape has no way to jump straight to track seven — you play through everything before it. Sequential file organization works the same way: records are stored one after another, and reading record number 500 means reading through the 499 before it. This is fine, even ideal, when a program always processes every record in order.

03

Direct: a music streaming app

A streaming app lets you tap any song and hear it instantly, no scrubbing through everything before it. Direct — or random-access — file organization does this by computing a record's exact location from its key, using precisely the hashing idea from Lessons 3 and 4, applied to file offsets instead of array slots.

04

Indexed-sequential: a textbook's index page

A textbook lets you look up a topic in its index, jump straight to the right page, and then read sequentially from there — a hybrid of the two ideas above. Indexed-sequential file organization keeps records in sequential order for full scans, while also keeping a small index that maps keys to approximate positions for fast direct lookups when you only need one record.

Try it yourself

A bank needs to print monthly statements for all ten million accounts in account-number order, and also needs to answer 'what is the balance of account X' instantly at an ATM. Which file organization fits each need, and can one system serve both?

Need a hint?

One need processes every record in order; the other needs exactly one record, fast, without scanning.

Check the worked solution

The monthly statement run is a full sequential scan, well served by sequential organization. The ATM balance check is a single direct lookup, well served by direct organization. A real bank typically uses indexed-sequential organization precisely because it serves both reasonably well from one file, avoiding the cost of maintaining two separate copies of the same ten million accounts.

Quick check

Which file organization is the natural fit for a program that must process every record in order, every time, and never needs to jump to one specific record?

Select an answer to check your thinking.

Why this lesson exists

Syllabus mapping

Data hierarchy · File Attributes · File Organization

Maps to course outcomes CO1, CO4.