Professional Documents
Culture Documents
Chapter 16
Disk Storage,
Basic File Structures, and
Hashing
Part2
1
2
File Organization
The database is stored as a collection of files.
3
File, Fixed Length Records, and
saves space.
the starting position and size of each field is
5
Blocking Factor
Blocking Factor (bfr) - the number of records that can
fit into a single block.
Bfr ( no of records in the block) = ⌊B/R⌋
B : Block size in bytes
R: Record size in bytes
Example:
Record size R = 225 bytes,
Block Size B = 2,000 bytes,
File size= 100000 record,
7
Placing File Records on Disk
Unspanned Records
Spanned Records
8
Types of records organization
Spanned & Unspanned Records
Unspanned records:
A record is found in one and only one block.
records do not span(not divided) across block
boundaries.
Used with fixed-length records having B R
Spanned records:
Records are been allowed to span across block
boundaries.
Used with variable-length records having R B
A pointer at the end of the first block points to
the block containing the remainder of the
record, not the next consecutive block on disk.
9
Types of records organization
Spanned & Unspanned Records
10
Allocating File Blocks on Disk
The physical disk blocks that are allocated to hold the
records of a file can be contiguous, linked, or indexed.
11
Operation on Files
Operation on files are :
12
Operation on Files.cont
Typical file operations ( access methods) include:
OPEN: Prepares the file for reading or writing , sets the file pointer to
the beginning of the file.
FIND: Searches for the first file record that satisfies a certain
condition, and makes it the current file record.
FINDNEXT: Searches for the next file record (from the current
record) that satisfies a certain condition, and makes it the current file
record.
INSERT: Inserts a new record into the file & makes it the current file
record.
13
Operation on Files.cont
14
Organization of Records in Files
15
Files of unordered records (Heap File)
Records are placed in the file in the order in which
they are inserted. Such an organization is called a
heap or pile file.
It is a simplest and most basic types of organization
Insertion : inserting a new record at the end of
file.
(very efficient)
Searching
requires a linear search (expensive)
Deleting
requires a linear search, then delete.
Leaves unused space in the disk block.
16
Heap File Organization
Either spanned or unspanned organization with
fixed length or variable length records can be used
for an unordered file (Heap file).
17
Hashing Techniques
18