170 likes | 355 Views
Data Base Organization and File Structure. Suresh Choubey, Ph.D. File Structure. Storage hierarchy of computer storage media ? primary storage main + cache Fast access but limited storage capacity volatile storage secondary storage magnetic disks & tapes
E N D
Data Base Organization and File Structure Suresh Choubey, Ph.D. Data Base Organization and File Structure: Introduction
File Structure • Storage hierarchy of computer storage media ? • 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
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 Data Base Organization and File Structure: Introduction
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 • movable head disk – and acutuator is used • ransfer time = seek time + block transfer time • random access device Data Base Organization and File Structure: Introduction
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 • saves seek time and rotational delay Data Base Organization and File Structure: Introduction
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 • 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
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 • 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
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 Data Base Organization and File Structure: Introduction
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. • Here unused space = B – (bfr * R) bytes. Data Base Organization and File Structure: Introduction
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 Data Base Organization and File Structure: Introduction
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 • here bfr is average # of records per block. • # of blocks required = [r/bfr] blocks Data Base Organization and File Structure: Introduction
File Structure • Advantage of blocking • Blocking reduces #of data transfer operations • Blocking reduces # of interblock gaps Data Base Organization and File Structure: Introduction
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 • Advantage: file expansion is possible • Disadvantage: slow reading of who file Data Base Organization and File Structure: Introduction
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 Data Base Organization and File Structure: Introduction
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 Data Base Organization and File Structure: Introduction
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 Data Base Organization and File Structure: Introduction
File Structure • File Organizations • Refers to organization of data of a file into records , blocks, and access structures. • Access Methods • 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