No Slide Title
Download
Report
Transcript No Slide Title
Data Base Organization
and File Structure
Suresh Choubey, Ph.D.
July 7, 2015
Data Base Organization and File
Structure: Introduction
1
File Structure
Storage hierarchy of computer storage media ?
July 7, 2015
primary storage main + cache
Fast access but limited storage capacity
volatile storage
secondary storage magnetic disks & tapes
Large capacity ,lower cost but slower access
non – volatile storage
Data Base Organization and File
Structure: Introduction
2
File Structure
Storage hierarchy of computer storage media ?
Data bases store large amount of data that must
persist over long periods of time
Magnetic tapes are off line – used for backup
enter record gap of 0.6
sequential access
Magnetic disks are on-line and data is organized as
files of records
July 7, 2015
Data Base Organization and File
Structure: Introduction
3
File Structure
H/W address of a block = combination of surface
number, track # & block #
fixed head disk - # of read/write heads are fixed and
are equal to the number of tracks
July 7, 2015
movable head disk – and acutuator is used
ransfer time = seek time + block transfer time
random access device
Data Base Organization and File
Structure: Introduction
4
File Structure
Buffering of blocks
most useful when processes can run concurrently in a simultaneous
fashion (multiple processors may enlist or a special I/O processor)
Double buffering
CPU can start processing a block once its transfer to main memory
is completed, while at the same time the disk I/O processor reads
and transfers the next block into a different buffer
July 7, 2015
saves seek time and rotational delay
Data Base Organization and File
Structure: Introduction
5
File Structure
Record Types:
Each record consists of related data values or items
Each value corresponds to a field of record and takes a few bytes
Records type or record format: a collection of fields with their data
type
July 7, 2015
A file is a sequence of records
File of fixed – length records: If every record in file has the same size (in bytes)
File of variable – length records: different sizes
Data Base Organization and File
Structure: Introduction
6
File Structure
Why variable length Records?
File records are of same type but fields are of variable size (variable
length fields) e.g. variable length name
File records are of same type but one or more fields may have
multiple value for individual records
such fields are called repeating field and a group of values for field is
called repeating
July 7, 2015
File records are of same type but one or more fields are optional
File contains records of different record types and hence of varying
size (mixed file)
Data Base Organization and File
Structure: Introduction
7
File Structure
Storing the Records:
Files of fixed length records: field locations w.r.t.
beginning of records is known
Files of variable length records: (a) use separator
character, (b) each record as a set of < field name,
field value > pairs, (c) < field type, field value > pair
July 7, 2015
Data Base Organization and File
Structure: Introduction
8
File Structure
Record Blocking: Spanned vs Unspanned Records
Let B = block size
R = record size of file of fixed-length records
Let there exists a R, then bfr = [(B/R)], where bfr =
blocking factor for the file.
July 7, 2015
Here unused space = B – (bfr * R) bytes.
Data Base Organization and File
Structure: Introduction
9
File Structure
Spanned organization: to utilize this unused space,
a record can be stored in next block or in some
other block (using a pointer to point to that block)
Here record is spanned over more than one block.
used with variable length record
should be used if record size is large, otherwise wastage
will be too high
July 7, 2015
Data Base Organization and File
Structure: Introduction
10
File Structure
Unspanned organization: if we do not allow
records to cross block boundaries
used with fixed length record
simplifies record processing as every record starts at
one location
July 7, 2015
here bfr is average # of records per block.
# of blocks required = [r/bfr] blocks
Data Base Organization and File
Structure: Introduction
11
File Structure
Advantage of blocking
July 7, 2015
Blocking reduces #of data transfer operations
Blocking reduces # of interblock gaps
Data Base Organization and File
Structure: Introduction
12
File Structure
Allocating file blocks on disks
Contiguous allocation: efile blocks are allocated to consecutive disk
blocks.
Advantage: fast reading of whole file using double buffering
Disadvantage: file cannot be expanded.
Linked allocation: each file block contains a pointer to the next
file block
July 7, 2015
Advantage: file expansion is possible
Disadvantage: slow reading of who file
Data Base Organization and File
Structure: Introduction
13
File Structure
Allocating file blocks on disks
Clusters: clusters of consecutive disk blocks and clusters
are linked.
-- combination of above two
-- clusters are also called segments or extents
Indexed allocation: one or more index blocks contain
pointers to the actual file blocks
July 7, 2015
Data Base Organization and File
Structure: Introduction
14
File Structure
File descriptions or file headers
Contains information to determine disk address of the file
blocks as well as record format descriptions (such as field
length) order of fields within a record for fixed length
unspanned records and field type code, separator
characters and record type codes for variable–length
records
July 7, 2015
Data Base Organization and File
Structure: Introduction
15
File Structure
Operations on File
Find (or locate)
Read (or Get)
Find Next (record at a time operation)
Delete
Modify
Insert
Find all
Find ordered – set at a time operations
Reorganize
July 7, 2015
Data Base Organization and File
Structure: Introduction
16
File Structure
File Organizations
Refers to organization of data of a file into records , blocks, and
access structures.
Access Methods
July 7, 2015
Consists of a group of programs that allow operations as above
File may be static (update operations are rarely performed).
volatile (update information are a
Data Base Organization and File
Structure: Introduction
17