Variable Length Data and Records

Download Report

Transcript Variable Length Data and Records

Variable Length Data and
Records
- Ashwin Kalbhor
Class ID : 107
Agenda
 Records
with Variable Length
Fields
 Records with Repeating Fields
 Variable Format Records
 Records that do not fit in a block

Example of a record
name
0
address
30
gender
286
birth date
287
297
Records with Variable Length Fields

Simple and Effective way to represent variable
length records is as follows –
1. Fixed length fields are kept ahead of the
variable length records.
2. A header is put in front of the of the record.
3. Record header contains
• Length of the record
• Pointers to the beginning of all variable
length fields except the first one.
Example
header information
record length
to address
gender
birth date
name
address
Record with name and address as variable length field.
Records with repeating fields
Repeating fields simply means fields of the
same length L.
 All occurrences of Field F grouped
together.
 Pointer pointing to the first field F is put
in the header.
 Based on the length L the starting offset
of any repeating field can be obtained.

Example of a record with Repeating
Fields
other header information
record length
to address
to movie pointers
name
address
Movie star record with “movies” as the repeating field.
pointers to movies
Alternative representation
Record is of fixed length
 Variable length fields stored on a separate
block.
 The record itself keeps track of 1. Pointers to the place where each
repeating field begins, and
2. Either how many repetitions there are,
or where the repetitions end.

Storing variable length fields
separately from the record.
Variable Format Records
Records that do not have fixed schema
 Represented by sequence of tagged fields
 Each of the tagged fields consist of information
• Attribute or field name
• Type of the field
• Length of the field
• Value of the field

Variable Format Records
code for name
code for string type
length
N
S
14
Clint Eastwood
code for restaurant owned
code for string type
length
R
S
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 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 a 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
Spanned Records
block header
record header
record 1
block 1
record
2-a
record
2-b
block 2
record 3
Thank You.