CS257_13.7_Vijaya Pamidi_102

Download Report

Transcript CS257_13.7_Vijaya Pamidi_102

VIJAYA PAMIDI
CS 257- Sec 01
ID:102
Topics
•
•
•
•
•
Records with Variable Length Fields
Records with Repeating Fields
Variable Format Records
Records that do not fit in a block
BLOBS
Example
name
address
gender
birth date
0 30 286 287 297
Fig 1 : Movie star record with four fields
Records with Variable 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
o
o
Length of the record
Pointers to the beginning of all variable
length fields except the first one.
Records with Variable Length
Fields
header information
record length
to address
gender birth date
name
address
Figure 2 : A Movie Star record with name and address
implemented as variable length character strings
Records with Repeating Fields
• Records contains variable number of occurrences of a
field F
• 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
o 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
o We stop upon reaching the offset of the field F.
Records with Repeating
Fields
other header
information
record length
to address
to movie pointers
name
address
pointers to movies
Figure 3 : A record with a repeating group of references to
Records with Repeating Fields
record header to name length of name
information
to address
length of address
to movie references
number of
references
address
name
Figure 4 : Storing variable-length fields separately from the
record
Records with Repeating Fields
Advantage
• 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.
Disadvantage
• Storing variable length components on another block
increases the number of disk I/O’s needed to examine
all components of a record.
Records with Repeating Fields
A compromise strategy is to allocate a fixed
portion of the record for the 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
Variable Format Records
• Records that do not have fixed schema
• Variable format records are represented by sequence
of
tagged fields
• Each of the tagged fields consist of information
o Attribute or field name
o Type of the field
o Length of the field
o Value of the field
• Why use tagged fields
o Information – Integration applications
o Records with a very flexible schema
Variable Format Records
code for name
code for string type
length
N
S 14
code for restaurant owned
Clint Eastwood R
code for string type
length
S
Fig 5 : A record with tagged fields
16
Hog’s Breath Inn
Records that do not fit in a block
• When the length of a record is greater than block size
,then
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
• 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
Records that do not fit in a block
block header
record header
record 1
block 1
record
2-a
record
2-b
record 3
block 2
Figure 6 : Storing spanned records across blocks
BLOBS
• Large binary objects are called BLOBS
e.g. : audio files, video files
• Storage of BLOBS
• Retrieval of BLOBS