13.5 Arranging data on disk Meghna Jain ID-205CS257 Prof: Dr. T.Y.Lin
Data elements are represented as records, which stores in consecutive bytes in same same disk block. Basic layout techniques of storing data : Fixed-Length Records Allocation criteria - data should start at word boundary. Fixed Length record header 1. A pointer to record schema. 2. The length of the record. 3. Timestamps to indicate last modified or last read. 3. Timestamps to indicate last modified or last read.
Example Example CREATE TABLE employee( name CHAR(30) PRIMARY KEY, address VARCHAR(255), gender CHAR(1), birthdate DATE ); Data should start at word boundary and contain header and four fields name, address, gender and birthdate.
Packing Fixed-Length Records into Blocks : Records are stored in the form of blocks on the disk and they move into main memory when we need to update or access them. A block header is written first, and it is followed by series of blocks.
Block header contains the following information : Links to one or more blocks that are part of a network of blocks. Links to one or more blocks that are part of a network of blocks. Information about the role played by this block in such a network. Information about the role played by this block in such a network. Information about the relation, the tuples in this block belong to. Information about the relation, the tuples in this block belong to. A "directory" giving the offset of each record in the block. A "directory" giving the offset of each record in the block. Time stamp(s) to indicate time of the block's last modification and/or access. Time stamp(s) to indicate time of the block's last modification and/or access.
Example Along with the header we can pack as many record as we can in one block as shown in the figure and remaining space will be unused.
Thank You