RecordPage Formats - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

RecordPage Formats

Description:

All fields can be placed continous ... UNPACKED, BITMAP. Slot 1. Slot 2. Slot N. Free. Space. Slot M. 1. 1. number. of records. number ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 17
Provided by: ev9
Category:

less

Transcript and Presenter's Notes

Title: RecordPage Formats


1
Record/Page Formats
  • Esezer_at_ata.cs.hun.edu.tr

2
Record Formats
  • Organization of records whether field length of
    record
  • Fixed
  • Variable
  • Not Type and number of fields are identical for
    all
    toples

3
Fixed Length Records
F1
F2
F3
F4
L1
L2
L3
L4
Base address (B)
Address BL1L2
  • All fields can be placed continous
  • Finding ith field address requires adding length
    of previous fields to base address.

4
Variable Length Records
  • Two alternative formats ( fields is fixed)

F1 F2 F3
F4
Fields Delimited by Special Symbols
Field Count
F1 F2 F3 F4
Array of Field Offsets

5
Variable Length Records(Cont.)
  • In first
  • All previous fields must be scanned to acces
    desired records
  • In Second
  • Second offers direct access to i.th field
  • Points begin and end of the field
  • Efficient storage for nulls
  • Small directory overhead

6
Disadvantage of Variable Length
  • If field is growth to larger size,
  • Subsequent fields must be shifted
  • Offsets must be updated
  • If changing of field length requires passing to
    another page,
  • memory adres of page is changed
  • Refernces to old address must be updated
  • If changing of field length requires locating on
    more pages
  • Chaining must be set up for record

7
Page Formats Fixed Length Records
Slot 1
Slot 1
Slot 2
Slot 2
Free Space
. . .
. . .
Slot N
Slot N
Slot M
N
M
1
0
. . .
1
1
M ... 3 2 1
number of records
number of slots
PACKED
UNPACKED, BITMAP
  • In first alternative, moving records for free
    space management changes memory address of record
    may not be acceptable.

8
Page Formats Variable Length Records
Rid (i,N)
Page i
Rid (i,2)
Rid (i,1)
N
Pointer to start of free space
20
16
24
N . . . 2 1
slots
SLOT DIRECTORY
  • Can move records on page without changing memory
    address of records so, attractive for
    fixed-length records too.

9
Page Formats Var. Leng. Recs.
  • Keep a directory for slots that show ltrecord
    offset, record lengthgt
  • Keep a pointer to point free space
  • For placement a record
  • If it is possible, insert in free space
  • Reorganize page to combine wasted space then
    insert
  • Insert another page
  • For deleting a record
  • Put 1 to record offset information in directory

10
Files of Records
  • Page or block is OK when doing I/O, but higher
    levels of DBMS operate on records, and files of
    records.
  • FILE A collection of pages, each containing a
    collection of records. Must support
  • insert/delete/modify record
  • read a particular record
  • scan all records (possibly with some conditions
    on the records to be retrieved)

11
Unordered (Heap) Files
  • Simplest file structure contains records in no
    particular order.
  • As file grows and shrinks, disk pages are
    allocated and de-allocated.
  • To support record level operations, we must
  • keep track of the pages in a file
  • keep track of free space on pages
  • keep track of the records on a page
  • There are many alternatives for keeping track of
    this.

12
Heap File Implemented as a List
Data Page
Data Page
Data Page
Full Pages
Header Page
Data Page
Data Page
Data Page
Pages with Free Space
  • The header page id and Heap file name must be
    stored someplace on disk.
  • Each page contains two pointers plus data.

13
Heap File Using a Page Directory
  • The entry for a page can include the number of
    free bytes on the page.
  • The directory is a collection of pages linked
    list implementation is just one alternative

14
Indexes
  • Sometimes, we want to retrieve records by
    specifying the values in one or more fields,
    e.g.,
  • Find all students in the CS department
  • Find all employees with a age gt 30
  • Indexes are file structures that enable us to
    answer such value-based queries efficiently.

15
System Catalogs
  • For each index
  • structure (e.g., B tree) and search key fields
  • For each relation
  • name, file name, file structure (e.g., Heap file)
  • attribute name and type, for each attribute
  • index name, for each index
  • integrity constraints
  • For each view
  • view name and definition
  • Plus statistics, authorization, buffer pool size,
    etc.
  • Catalogs are themselves stored as tables!

16
Attr_Cat(attr_name, rel_name, type, position)
Write a Comment
User Comments (0)
About PowerShow.com