If Fixed-Length Records
Consider the page to be broken into uniform slots, where the
slot size is equal to the record size. An rid will
be represented as < pageID, slot#>
How to handle insertions and deletions depends on whether such
rid's are held externally. If we are allowed to move
arbitrarily reorganize records, than we can efficiently ensure that
all N records are kept in the first N slots of the page. However, if
a record's rid must remain consistent, then we will have to leave
"holes" after a deletion, and will have to scan for open slots upon an
insertion.
If Variable-Length Records
With variable length records, we can no longer consider the page to be
broken into fixed slots, because we do not know what size slots to
use. Instead, we will have to devote available space in a page to
store a newly inserted record, if possible.
Again, our approach will depend greatly on whether or not we are
allowed to rearrange the order and placement of the records, at risk
of redefining a record's rid. If we are allowed to adjust the
placement of existing records, then we can always ensure that all of
the records are kept compactly at one end of the page, and that all
remaining freespace is contiguous at the other end of the page.
However, if the validity of rid's must be preserved over time, we must
adjust this approach. Our solution will be to add one level of
indirection in the rid. Rather than have the rid directly reference
the true placement of the record on the page, it can reference an
entry in a slot directory maintained on the page,
where that entry contains information about the true placement.
Though this change of approach may seem insignificant, it allows us to
internally rearrange the placement of the records of a page, so long
as we update the slot directory in accordance.
One additional subtlety is that we still must manage the use of
available entries in the slot directory as insertions and deletions of
records take place. An existing page's record ID is now represented
as
< pageID, slotDirectoryEntry >.