Madhuri Gollu
Id: 207
Records with Variable Length Fields
Records with Repeating Fields
Variable Format Records
Records that do not fit in a block
BLOBs
Column Stores
0 name
30 address gender birth date
286 287 297
Fig 1 : Movie star record with four fields
An effective way to represent variable length records is as follows
Fixed length fields are Kept ahead of the variable length fields
Record header contains
• Length of the record
• Pointers to the beginning of all variable length fields except the first one.
header information record length to address gender birth date name address
Fig 2 : A Movie Star record with name and address implemented as variable length character strings
Records contains variable number of occurrences of a field F, but the field itself is of fixed length.
All occurrences of field F are grouped together and the record header contains a pointer to the first occurrence of field F
L bytes are devoted to one instance of field F
Locating an occurrence of field F within the record
• Add to the offset for the field F which are the integer multiples of L starting with 0 , L ,2L,3L and so on to locate
• We stop whenever we reach the offset of the field F or end of the record.
other header information record length to address to movie pointers name address pointers to movies
Fig3 : A record with a repeating group of references to movies
record header information to name length of name to address length of address to movie references number of references
Record address name
Additional space
Fig4 : Storing variable-length fields separately from the record
Keeping the record itself fixed length allows record to be searched more efficiently, minimizes the overhead in the block headers, and allows records to be moved within or among the blocks with minimum effort.
Storing variable length components on another block increases the number of disk I/O’s needed to examine all components of a record.
A compromise strategy is to allocate a fixed-length portion of the record enough space for repeating fields
If the number of repeating fields is lesser than allocated space, then there will be some unused space
If the number of repeating fields is greater than allocated space, then extra fields are stored in a different location and
Pointer to that location and count of additional occurrences is stored in the record
Records that do not have fixed schema
Variable format records are represented by sequence of tagged fields, which has value of field preceded by information of this field
Each of the tagged fields consist of information
• Attribute or field name
• Type of the field
• Length of the field
code for name code for string type length code for restaurant owned code for string type length
N S 14 Clint Eastwood R S 16 Hog’s Breath Inn
Fig 5 : A record with tagged fields
When the length of a record is greater than block size
,then record is divided and placed into two or more blocks
Portion of the record in each block is referred to as a
RECORD FRAGMENT
Record with two or more fragments is called
SPANNED RECORD
Record that do not cross a block boundary is called
UNSPANNED RECORD
Spanned records require the following extra header information
• A bit indicates whether it is fragment or not
• A bit indicates whether it is first or last fragment of a record
• Pointers to the next or previous fragment for the same record
block header record header record 1 record
2 - a record
2 - b record 3 block 1 block 2
Fig 6 : Storing spanned records across blocks
Binary Large Objects are called BLOBs
Example : audio files, video files
Storage of BLOBs
It must be stored as sequence of blocks
Retrieval of BLOBs
Store each column as a record.
A relation may occupy more than a single block
We keep the values in each column in the same order , then we can reconstruct the relation from the column records.