Presentation is loading. Please wait.

Presentation is loading. Please wait.

Variable Length Data and Records

Similar presentations


Presentation on theme: "Variable Length Data and Records"— Presentation transcript:

1 Variable Length Data and Records
Dhivyakrishnan CS 257 ID: 105

2 Agenda Records with Variable Length Fields
Records with Repeating Fields Variable Format Records Records that do not fit in a block BLOBS

3 Example Fig 1 : Movie star record with four fields name address gender
birth date Fig 1 : Movie star record with four fields

4 Records with Variable Fields
An effective way to represent variable length records is as follows Fixed length fields are stored before the variable length fields Record header contains Length of the record Pointers to the beginning of all variable length fields except the first one.

5 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

6 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 The repeating field F is of fixed length L bytes Locating an occurrence of field F within the record Add offset for the field F which are the integer multiples of L starting with 0 , L ,2L,3L and so on to locate

7 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 movies

8 Records with Repeating Fields
record header information to name length of name to address length of address to movie references number of references address name Figure 4 : Storing variable-length fields separately from the record

9 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.

10 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

11 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 Attribute or field name Type of the field Length of the field Value of the field Why use tagged fields Information – Integration applications Records with a very flexible schema

12 Variable Format Records
code for name code for restaurant owned code for string type code for string type length length N S 14 Clint Eastwood R S 16 Hog’s Breath Inn Fig 5 : A record with tagged fields

13 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

14 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

15 Records that do not fit in a block
block header record header record 2 - b record 2 - a record 1 record 3 block 1 block 2 Figure 6 : Storing spanned records across blocks

16 BLOBS Large binary objects are called BLOBS
e.g. : audio files, video files Storage of BLOBS Retrieval of BLOBS

17 END


Download ppt "Variable Length Data and Records"

Similar presentations


Ads by Google