CSE Roadmap

Common tier · about 2 hours · 5 parts

Part 2 of 5 · 1 min read

Heap files

Records stored in no particular order, usually wherever there is free space.

Think of a drawer where papers are simply dropped in wherever there happens to be room, with no attempt to keep them in any particular order.

In plain words: a heap file stores records in no particular order, typically wherever free space is available. Inserting a new record is fast, since it can usually go anywhere with space. Finding a specific record, without an index, requires scanning the file from the start until it is found.

A worked example. A new order inserted into a heap-organized orders file goes into the first available free space, regardless of its order_id or placed_on date.

The key lines. No SQL; file organization is a storage-engine detail below the SQL layer, not something a query statement controls directly.

Heap file

A heap file stores records in no particular order, usually wherever free space allows. Inserting is fast; finding a specific record without an index requires scanning the whole file.

Example: a heap-organized table has no guaranteed physical order matching any column's values, so SELECT * FROM orders can return rows in an order unrelated to order_id or placed_on.