Page Format

What
The page format determines how records will be stored and organized on a page

Fixed Length Records
When all of the records on a page are the same length, we can store them consecutively in the page.

Insertion
When a record is inserted into a page, we must find an empty slot and put it there

Deletion
There are two ways to manage deletion of fixed length records

1. Have the records occupy the first N slots in the page. When a deletion occurs, move the last record into the newly vacated slot. Note: This approach will not work if there are external references to the record that just moved because we have just changed its slot number, and the reference does not update automatically



2. Maintain a bit vector of whether the slot is occupied. When a record is deleted, we turn that bit off. For this implementation, it will work even if there are external references to the record because we are not moving any records around.

Variable Length Records
The most flexible way to organize variable length records is to maintain a directory of slots. We need to maintain the record offset and the record length per slot. The record offset is a pointer


 * Deletion is accomplished by setting the record offset to -1


 * Records can be moved around on the page because the record id (page number, slot number) references a record by its slot number on a page but with this implementation, the slot number does not change, only the pointer to the beginning of the data does.


 * When data cannot fit into the free space anymore, we reorganize the records to be sequential in memory.
 * When we need to move a record, we leave a "tombstone" behind that points to a new (page number, slot number)