Slotted page (code by Claude, guidance by Georgios Evangelidis)

Records are packed from the start of the page; the slot directory grows backwards from the end, after a header holding the number of slots N and the free space pointer. A record id is (page, slot), so records can move inside the page (during compaction or a growing update) without their rid changing: only the slot's offset is rewritten.

Student record: sid, name, login, age, gpa
Slot number
Page
History
Records 0 Slots N 0 Free space pointer 0 Contiguous free 0 In holes 0 Record bytes 0 Directory and header 0

Selected record

Slot directory

SlotOffsetLengthsidname

Operation log

    Reading the diagram

    Record, labelled with its slot; the darker start is its field offset array
    Hole: space freed by a delete or a shrinking update, not reusable until compaction
    Contiguous free space, between the free space pointer and the directory
    Slot entry: record offset (2 bytes) and length (2 bytes)
    Header: free space pointer and N, 2 bytes each

    Each row is 64 bytes and the page reads left to right, top to bottom. Slot i sits at page offset size − 4 − 4(i + 1). A deleted slot stays in the directory, marked empty, so the slot numbers (and rids) of the other records do not change; only trailing empty slots are removed.

    Record format: an offset array of 6 two-byte entries (start of each of the 5 fields plus the end), then sid INTEGER (4), name VARCHAR(30), login VARCHAR(20), age INTEGER (4), gpa REAL (4).