Chapter 10: Storage and File Structures

Chapter 10: Storage and File Structure
Database System Concepts, 6th Ed.
©Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
File Organization, Record Organization
and Storage Access
Database System Concepts - 6th Edition
10.2
©Silberschatz, Korth and Sudarshan
File Organization
 The database is stored as a collection of files. Each file is a
sequence of records. A record is a sequence of fields.
 One approach:
assume
each
record size is fixed
file has records of one particular type only
different
files are used for different relations
This case is easiest to implement; will consider variable length
records later.
Database System Concepts - 6th Edition
10.3
©Silberschatz, Korth and Sudarshan
Fixed--Length Records
Fixed
 Simple approach:

Store record i starting from byte n  (i – 1), where n is the size of
each record.

Record access is simple but records may cross blocks

Modification: do not allow records to cross block boundaries
 Deletion of record i:
alternatives:

move records i + 1, . . ., n
to i, . . . , n – 1

move record n to i

do not move records, but
link all free records on a
free list
Database System Concepts - 6th Edition
10.4
©Silberschatz, Korth and Sudarshan
Deleting record 3 and compacting
Database System Concepts - 6th Edition
10.5
©Silberschatz, Korth and Sudarshan
Deleting record 3 and moving last record
Database System Concepts - 6th Edition
10.6
©Silberschatz, Korth and Sudarshan
Free Lists
 Store the address of the first deleted record in the file header.
 Use this first record to store the address of the second deleted record,
and so on
 Can think of these stored addresses as pointers since they “point” to
the location of a record.
 More space efficient representation: reuse space for normal attributes
of free records to store pointers. (No pointers stored in in-use records.)
Database System Concepts - 6th Edition
10.7
©Silberschatz, Korth and Sudarshan
Variable--Length Records
Variable
 Variable-length records arise in database systems in several ways:

Storage of multiple record types in a file.

Record types that allow variable lengths for one or more fields such as
strings (varchar)

Record types that allow repeating fields (used in some older data
models).
 Attributes are stored in order
 Variable length attributes represented by fixed size (offset, length), with
actual data stored after all fixed length attributes
 Null values represented by null-value bitmap
Database System Concepts - 6th Edition
10.8
©Silberschatz, Korth and Sudarshan
Variable--Length Records: Slotted Page Structure
Variable
 Slotted page header contains:

number of record entries

end of free space in the block

location and size of each record
 Records can be moved around within a page to keep them contiguous
with no empty space between them; entry in the header must be
updated.
 Pointers should not point directly to record — instead they should
point to the entry for the record in header.
Database System Concepts - 6th Edition
10.9
©Silberschatz, Korth and Sudarshan
Organization of Records in Files
 Heap – a record can be placed anywhere in the file where there
is space
 Sequential – store records in sequential order, based on the
value of the search key of each record
 Hashing – a hash function computed on some attribute of each
record; the result specifies in which block of the file the record
should be placed
 Records of each relation may be stored in a separate file. In a
multitable clustering file organization records of several
different relations can be stored in the same file

Motivation: store related records on the same block to
minimize I/O
Database System Concepts - 6th Edition
10.10
©Silberschatz, Korth and Sudarshan
Sequential File Organization
 Suitable for applications that require sequential processing of
the entire file
 The records in the file are ordered by a search-key
Database System Concepts - 6th Edition
10.11
©Silberschatz, Korth and Sudarshan
Sequential File Organization (Cont.)
 Deletion – use pointer chains
 Insertion –locate the position where the record is to be inserted

if there is free space insert there

if no free space, insert the record in an overflow block

In either case, pointer chain must be updated
 Need to reorganize the file
from time to time to restore
sequential order
Database System Concepts - 6th Edition
10.12
©Silberschatz, Korth and Sudarshan
Multitable Clustering File Organization
Store several relations in one file using a multitable clustering
file organization
department
instructor
multitable clustering
of department and
instructor
Database System Concepts - 6th Edition
10.13
©Silberschatz, Korth and Sudarshan
Multitable Clustering File Organization (cont.)
 good for queries involving department
instructor, and for queries
involving one single department and its instructors
 bad for queries involving only department
 results in variable size records
 Can add pointer chains to link records of a particular relation
Database System Concepts - 6th Edition
10.14
©Silberschatz, Korth and Sudarshan
Data Dictionary Storage
The Data dictionary (also called system catalog) stores
metadata; that is, data about data, such as
 Information about relations

names of relations
names, types and lengths of attributes of each relation
 names and definitions of views
 integrity constraints
User and accounting information, including passwords
Statistical and descriptive data
 number of tuples in each relation
Physical file organization information
 How relation is stored (sequential/hash/…)
 Physical location of relation
Information about indices (Chapter 11)





Database System Concepts - 6th Edition
10.15
©Silberschatz, Korth and Sudarshan
Relational Representation of System Metadata
 Relational
representation on
disk
 Specialized data
structures
designed for
efficient access, in
memory
Database System Concepts - 6th Edition
10.16
©Silberschatz, Korth and Sudarshan
Download PDF
Similar pages