SlideShare una empresa de Scribd logo
1 de 41
Chapter 1: File Organization 
Database System Concepts, 6th Ed. 
©Silberschatz, Korth and Sudarshan 
See www.db-book.com for conditions on re-use
Chapter 1: Storage and File Structure 
 Overview of Physical Storage Media 
 Magnetic Disks 
 RAID 
 Tertiary Storage 
 Storage Access 
 File Organization 
 Organization of Records in Files 
 Data-Dictionary Storage 
Database System Concepts - 6th Edition 10.2 ©Silberschatz, Korth and Sudarshan
Classification of Physical Storage Media 
 Speed with which data can be accessed 
 Cost per unit of data 
 Reliability 
 data loss on power failure or system crash 
 physical failure of the storage device 
 Can differentiate storage into: 
 volatile storage: loses contents when power is switched off 
 non-volatile storage: 
 Contents persist even when power is switched off. 
 Includes secondary and tertiary storage, as well as batter-backed 
up main-memory. 
Database System Concepts - 6th Edition 10.3 ©Silberschatz, Korth and Sudarshan
Physical Storage Media 
 Cache – fastest and most costly form of storage; volatile; managed 
by the computer system hardware. 
 Main memory: 
 fast access (10s to 100s of nanoseconds; 1 nanosecond = 10–9 
seconds) 
 generally too small (or too expensive) to store the entire 
database 
 capacities of up to a few Gigabytes widely used currently 
 Capacities have gone up and per-byte costs have 
decreased steadily and rapidly (roughly factor of 2 every 2 
to 3 years) 
 Volatile — contents of main memory are usually lost if a power 
failure or system crash occurs. 
Database System Concepts - 6th Edition 10.4 ©Silberschatz, Korth and Sudarshan
Physical Storage Media (Cont.) 
 Flash memory 
 Data survives power failure 
 Data can be written at a location only once, but location can be 
erased and written to again 
 Can support only a limited number (10K – 1M) of write/erase 
cycles. 
 Erasing of memory has to be done to an entire bank of 
memory 
 Reads are roughly as fast as main memory 
 But writes are slow (few microseconds), erase is slower 
 Widely used in embedded devices such as digital cameras, 
phones, and USB keys 
Database System Concepts - 6th Edition 10.5 ©Silberschatz, Korth and Sudarshan
Physical Storage Media (Cont.) 
 Magnetic-disk 
 Data is stored on spinning disk, and read/written magnetically 
 Primary medium for the long-term storage of data; typically stores entire 
database. 
 Data must be moved from disk to main memory for access, and 
written back for storage 
 Much slower access than main memory (more on this later) 
 Direct-access – possible to read data on disk in any order, unlike 
magnetic tape 
 Capacities range up to roughly 1.5 TB as of 2009 
 Much larger capacity and cost/byte than main memory/flash memory 
 Growing constantly and rapidly with technology improvements (factor 
of 2 to 3 every 2 years) 
 Survives power failures and system crashes 
 disk failure can destroy data, but is rare 
Database System Concepts - 6th Edition 10.6 ©Silberschatz, Korth and Sudarshan
Physical Storage Media (Cont.) 
 Optical storage 
 non-volatile, data is read optically from a spinning disk using 
a laser 
 CD-ROM (700 MB) and DVD (4.7 to 17 GB) most popular 
forms 
 Write-one, read-many (WORM) optical disks used for archival 
storage (CD-R, DVD-R, DVD+R) 
 Multiple write versions also available (CD-RW, DVD-RW, 
DVD+RW, and DVD-RAM) 
 Reads and writes are slower than with magnetic disk 
 Juke-box systems, with large numbers of removable disks, a 
few drives, and a mechanism for automatic loading/unloading 
of disks available for storing large volumes of data 
Database System Concepts - 6th Edition 10.7 ©Silberschatz, Korth and Sudarshan
Physical Storage Media (Cont.) 
 Magnetic Tape storage 
 non-volatile, used primarily for BACKUP (to recover from disk 
failure), and for ARCHIVAL DATA. 
 sequential-access – much slower than disk 
 very high capacity (40 to 300 GB tapes available) 
 tape can be removed from drive  storage costs much 
cheaper than disk, but drives are expensive 
 Tape jukeboxes available for storing massive amounts of 
data 
 hundreds of terabytes (1 terabyte = 109 bytes) to even 
multiple petabytes (1 petabyte = 1012 bytes) 
Database System Concepts - 6th Edition 10.8 ©Silberschatz, Korth and Sudarshan
Storage Hierarchy 
Database System Concepts - 6th Edition 10.9 ©Silberschatz, Korth and Sudarshan
Storage Hierarchy (Cont.) 
 Primary storage: Fastest media but volatile (cache, MM). 
 Secondary storage: next level in hierarchy, non-volatile, 
moderately fast access time 
 also called on-line storage 
 Online data storage refers to the practice of storing electronic data with a 
third party service accessed via the Internet.(Printer) 
 E.g. flash memory, magnetic disks 
 Tertiary storage: lowest level in hierarchy, non-volatile, slow 
access time 
 also called off-line storage 
 The term used to describe any storage medium that must be inserted into a 
storage drive by a person before it can be accessed by the computer system 
is considered to be a type of off-line storage. Offline storage may also be 
written as off-line storage and is also called removable storage. 
 E.g. magnetic tape, optical storage 
Database System Concepts - 6th Edition 10.10 ©Silberschatz, Korth and Sudarshan
Magnetic Hard Disk Mechanism 
NOTE: Diagram is schematic, and simplifies the structure of actual disk drives 
Database System Concepts - 6th Edition 10.11 ©Silberschatz, Korth and Sudarshan
Single Disk 
Block – 
• a contiguous sequence of sectors from a 
single track 
• data is transferred between disk and main 
memory in blocks 
• sizes range from 512 bytes to several 
kilobytes: 
• Smaller blocks: more transfers from disk. 
• Larger blocks: more space wasted due to 
partially filled blocks 
• Typical block sizes today range from 4 to16 
kilobytes 
Database System Concepts - 6th Edition 10.12 ©Silberschatz, Korth and Sudarshan
Magnetic Disks 
 Read-write head 
 Positioned very close to the platter surface (almost touching it) 
 Reads or writes magnetically encoded information. 
 Surface of platter divided into circular tracks 
 Over 50K-100K tracks per platter on typical hard disks 
 Each track is divided into sectors. 
 A sector is the smallest unit of data that can be read or written. 
 Sector size typically 512 bytes 
 Typical sectors per track: 500 to 1000 (on inner tracks) to 1000 to 2000 (on 
outer tracks) 
 To read/write a sector 
 disk arm swings to position head on right track 
 platter spins continually; data is read/written as sector passes under head 
 Head-disk assemblies 
 multiple disk platters on a single spindle (1 to 5 usually) 
 one head per platter, mounted on a common arm. 
 Cylinder c consists of i th track of all the platters 
Database System Concepts - 6th Edition 10.13 ©Silberschatz, Korth and Sudarshan
Disk Subsystem 
 Disk controller – 
 Interfaces between the computer system and the disk drive hardware. 
 multiple disks connected to a computer system through a controller 
 controllers functionality: checksum, bad sector remapping. 
Database System Concepts - 6th Edition 10.14 ©Silberschatz, Korth and Sudarshan
RAID 
 RAID: Redundant Arrays of Independent Disks 
 Disk organization techniques that manage a large numbers of disks, 
providing a view of a single disk of 
 high capacity and high speed by using multiple disks in parallel, 
 high reliability by storing data redundantly, so that data can be 
recovered even if a disk fails 
Database System Concepts - 6th Edition 10.15 ©Silberschatz, Korth and Sudarshan
About file…….. 
File System 
system provides so that users can manage information 
as a collection of files 
11-16 
 A file is a named collection of related data 
 A file system is the logical view that an operating 
 A file system is often organized by grouping files into 
directories 
Database System Concepts - 6th Edition 10.16 ©Silberschatz, Korth and Sudarshan
Properties: Fast, expensive, 
volatile, small 
- type: disks, tapes 
- properties: Slow , cheap, stable, 
large 
17 
Computer Architecture 
Main Memory 
(RAM) 
data 
transfer 
Secondary 
Storage 
Data is 
manipulated 
here 
Data is 
stored here 
Database System Concepts - 6th Edition 10.17 ©Silberschatz, Korth and Sudarshan
: 
Main memory 
Expensive – compared to secondary and tertiary storage 
Fast – in memory operations are fast 
Volatile – not possible to save data from one run to its next 
Used for storing current data 
Secondary storage (hard disk) 
Less expensive – compared to main memory 
Slower – compared to main memory, faster compared to tapes 
Persistent – data from one run can be saved to the disk to be used in the 
next run 
Used for storing the database 
Tertiary storage (tapes) 
Cheapest 
Slowest – sequential data access 
Used for data archives 
Database System Concepts - 6th Edition 10.18 ©Silberschatz, Korth and Sudarshan
File systems and databases 
• file: sequence of bytes stored on a computer 
: A collection of records or documents dealing with one organization, 
person, area or subject. 
• file system: software that provides hierarchical storage and 
organization of files, usually on a single computer 
• Database: integrated collection of logically related records – 
data is organized and structured for efficient systematic access . 
• Database system: software that provides efficient access to 
information in a database 
Database System Concepts - 6th Edition 10.19 ©Silberschatz, Korth and Sudarshan
Physical Files and Logical 
Files 
• Physical file: 
• A collection of bytes stored on a disk or tape. 
Physical files hold the actual data of a database file 
HOW: Data and records stored on physical device and how the 
operation are made possible. 
• Logical file: An “interface" that allows the application 
programs to access the physical file. 
WHAT: Data and records stored view by logical file and what 
kind of operations may be performed on the file. 
Database System Concepts - 6th Edition 10.20 ©Silberschatz, Korth and Sudarshan
Physical file: O.S: Logical file: 
It is actually a list of pointers to the physical file. 
The application program instruct the O.S. to find physical file 
named……?and then make connection by assigning a logical file to it. 
Application Program 
O.S. 
Secondary Storage Device 
Logical File 
Physical File 
Database System Concepts - 6th Edition 10.21 ©Silberschatz, Korth and Sudarshan
Fixed-length and Variable-length Records 
A file can contain: 
Fixed-length records - A file where all the records are of the exactly same length is 
said to have fixed length records. 
Advantage : 
Access is fast because the computer knows where each record starts. 
Eg: If each record is 120 bytes long then the 1st record starts at [Start of File] + 0 bytes 
the 2nd record starts at [Start of File] + 120 bytes 
the 3rd record starts at [Start of File] + 240 bytes etc..... 
Disadvantage : Using Fixed length records, the records are usually larger and 
therefore need more storage space and are slower to transfer (load or save). 
Database System Concepts - 6th Edition 10.22 ©Silberschatz, Korth and Sudarshan
Variable-length records - the length of each record varies 
One or more of the fields can be of differing lengths in each record, called variable length 
records 
Advantages:the records will be smaller and will need less storage space 
the records will load faster 
Disadvantages: 
The computer will be unable to determine where each record starts so processing the 
records will be slower. 
Database System Concepts - 6th Edition 10.23 ©Silberschatz, Korth and Sudarshan
Database System Concepts - 6th Edition 10.24 ©Silberschatz, Korth and Sudarshan
 . 
Text and Binary files 
 A binary file requires a specific interpretation of the bits 
11-25 
 In a text file the bytes of data are organized as 
characters from the ASCII or Unicode character sets 
based on the information in the file 
Database System Concepts - 6th Edition 10.25 ©Silberschatz, Korth and Sudarshan
File Operations 
 Create a file 
 Delete a file 
 Open a file 
 Close a file 
 Read data from a file 
 Write data to a file 
 Reposition the current file 
pointer in a file 
 Append data to the end of 
a file 
 Truncate a file (delete its 
contents) 
 Rename a file 
 Copy a file 
Database System Concepts - 6th Edition 10.26 ©Silberschatz, Kor1th1 a-2nd6 Sudarshan
File Access 
Figure: Sequential file access 
Database System Concepts - 6th Edition 10.27 ©Silberschatz, Korth and Sudarshan
File Access 
Figure: Direct file access 
Database System Concepts - 6th Edition 10.28 ©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 record size is fixed 
each 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.29 ©Silberschatz, Korth and Sudarshan
Fixed-Length Records 
 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.30 ©Silberschatz, Korth and Sudarshan
Deleting record 3 and compacting 
Database System Concepts - 6th Edition 10.31 ©Silberschatz, Korth and Sudarshan
Deleting record 3 and moving last record 
Database System Concepts - 6th Edition 10.32 ©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.33 ©Silberschatz, Korth and Sudarshan
Variable-Length Records 
 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.34 ©Silberschatz, Korth and Sudarshan
Variable-Length Records: Slotted Page Structure 
 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.35 ©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.36 ©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.37 ©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.38 ©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 
Database System Concepts - 6th Edition 10.39 ©Silberschatz, Korth and Sudarshan
Storage Access 
 A database file is partitioned into fixed-length storage units called 
blocks. Blocks are units of both storage allocation and data 
transfer. 
 Database system seeks to minimize the number of block transfers 
between the disk and memory. We can reduce the number of 
disk accesses by keeping as many blocks as possible in main 
memory. 
 Buffer – portion of main memory available to store copies of disk 
blocks. 
 Buffer manager – subsystem responsible for allocating buffer 
space in main memory. 
Database System Concepts - 6th Edition 10.40 ©Silberschatz, Korth and Sudarshan
Buffer Manager 
 Programs call on the buffer manager when they need a block 
from disk. 
1. If the block is already in the buffer, buffer manager returns 
the address of the block in main memory 
2. If the block is not in the buffer, the buffer manager 
1. Allocates space in the buffer for the block 
1. Replacing (throwing out) some other block, if required, 
to make space for the new block. 
2. Replaced block written back to disk only if it was 
modified since the most recent time that it was written 
to/fetched from the disk. 
2. Reads the block from the disk to the buffer, and returns 
the address of the block in main memory to requester. 
Database System Concepts - 6th Edition 10.41 ©Silberschatz, Korth and Sudarshan

Más contenido relacionado

La actualidad más candente

Free Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSFree Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSUnited International University
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
Query evaluation and optimization
Query evaluation and optimizationQuery evaluation and optimization
Query evaluation and optimizationlavanya marichamy
 
Modern operating system.......
Modern operating system.......Modern operating system.......
Modern operating system.......vignesh0009
 
Microsoft Windows File System in Operating System
Microsoft Windows File System in Operating SystemMicrosoft Windows File System in Operating System
Microsoft Windows File System in Operating SystemMeghaj Mallick
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsMukesh Chinta
 
Distributed databases and dbm ss
Distributed databases and dbm ssDistributed databases and dbm ss
Distributed databases and dbm ssMohd Arif
 
Distributed database system
Distributed database systemDistributed database system
Distributed database systemM. Ahmad Mahmood
 
Computer repair and maintenance
Computer repair and maintenanceComputer repair and maintenance
Computer repair and maintenanceCornelius Micah
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for filesZainab Almugbel
 
Distributed network
Distributed networkDistributed network
Distributed networkDhani Ahmad
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer networkAshita Agrawal
 

La actualidad más candente (20)

Free Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSFree Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFS
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Query evaluation and optimization
Query evaluation and optimizationQuery evaluation and optimization
Query evaluation and optimization
 
Remote backup system
Remote backup systemRemote backup system
Remote backup system
 
File system structure
File system structureFile system structure
File system structure
 
Networking ppt
Networking ppt Networking ppt
Networking ppt
 
File system
File systemFile system
File system
 
Disk management
Disk managementDisk management
Disk management
 
Modern operating system.......
Modern operating system.......Modern operating system.......
Modern operating system.......
 
Microsoft Windows File System in Operating System
Microsoft Windows File System in Operating SystemMicrosoft Windows File System in Operating System
Microsoft Windows File System in Operating System
 
Disk management
Disk managementDisk management
Disk management
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Distributed databases and dbm ss
Distributed databases and dbm ssDistributed databases and dbm ss
Distributed databases and dbm ss
 
Distributed database system
Distributed database systemDistributed database system
Distributed database system
 
Computer repair and maintenance
Computer repair and maintenanceComputer repair and maintenance
Computer repair and maintenance
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
 
Distributed network
Distributed networkDistributed network
Distributed network
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer network
 

Destacado

Destacado (9)

Xfs file system for linux
Xfs file system for linuxXfs file system for linux
Xfs file system for linux
 
Dbms
DbmsDbms
Dbms
 
Dbms
DbmsDbms
Dbms
 
File organization 1
File organization 1File organization 1
File organization 1
 
File Systems
File SystemsFile Systems
File Systems
 
Database management system
Database management systemDatabase management system
Database management system
 
Dbms slides
Dbms slidesDbms slides
Dbms slides
 
Database Management Systems (DBMS)
Database Management Systems (DBMS)Database Management Systems (DBMS)
Database Management Systems (DBMS)
 
Management Information System (MIS)
Management Information System (MIS)Management Information System (MIS)
Management Information System (MIS)
 

Similar a Ch 1-final-file organization from korth

Similar a Ch 1-final-file organization from korth (20)

Rdbms
Rdbms Rdbms
Rdbms
 
RDBMS
RDBMSRDBMS
RDBMS
 
Ch11
Ch11Ch11
Ch11
 
DB_ch11
DB_ch11DB_ch11
DB_ch11
 
storage and file structure
storage and file structurestorage and file structure
storage and file structure
 
Storage and file structure.ppt
Storage and file structure.pptStorage and file structure.ppt
Storage and file structure.ppt
 
Ch11 - Silberschatz
Ch11 - SilberschatzCh11 - Silberschatz
Ch11 - Silberschatz
 
ch11
ch11ch11
ch11
 
DownloadClassSessionFile (44).pdf
DownloadClassSessionFile (44).pdfDownloadClassSessionFile (44).pdf
DownloadClassSessionFile (44).pdf
 
Db
DbDb
Db
 
db
dbdb
db
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Storage structure1
Storage structure1Storage structure1
Storage structure1
 
storage & file strucure in dbms
storage & file strucure in dbmsstorage & file strucure in dbms
storage & file strucure in dbms
 
Magnetic disk - Krishna Geetha.ppt
Magnetic disk  - Krishna Geetha.pptMagnetic disk  - Krishna Geetha.ppt
Magnetic disk - Krishna Geetha.ppt
 
4_5837027281599466545_220608_094042.pdf
4_5837027281599466545_220608_094042.pdf4_5837027281599466545_220608_094042.pdf
4_5837027281599466545_220608_094042.pdf
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage Systems
 
Storage and File Structure in DBMS
Storage and File Structure in DBMSStorage and File Structure in DBMS
Storage and File Structure in DBMS
 
OSCh14
OSCh14OSCh14
OSCh14
 
OS_Ch14
OS_Ch14OS_Ch14
OS_Ch14
 

Más de Rupali Rana

Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsRupali Rana
 
Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsRupali Rana
 
Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsRupali Rana
 
Chapter 7: CONNECTED GRAPHS
Chapter 7: CONNECTED GRAPHSChapter 7: CONNECTED GRAPHS
Chapter 7: CONNECTED GRAPHSRupali Rana
 
Chapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHSChapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHSRupali Rana
 
Chapter 5: GRAPHS
Chapter 5: GRAPHSChapter 5: GRAPHS
Chapter 5: GRAPHSRupali Rana
 
Ch 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraCh 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraRupali Rana
 
Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbmsRupali Rana
 

Más de Rupali Rana (12)

Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphs
 
Ch 9 trees
Ch 9 treesCh 9 trees
Ch 9 trees
 
Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphs
 
Ch 9 trees
Ch 9 treesCh 9 trees
Ch 9 trees
 
Ch 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphsCh 8 eulerian and hamiltonian graphs
Ch 8 eulerian and hamiltonian graphs
 
Chapter 7: CONNECTED GRAPHS
Chapter 7: CONNECTED GRAPHSChapter 7: CONNECTED GRAPHS
Chapter 7: CONNECTED GRAPHS
 
Chapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHSChapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHS
 
Chapter 5: GRAPHS
Chapter 5: GRAPHSChapter 5: GRAPHS
Chapter 5: GRAPHS
 
Ch 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraCh 2 lattice & boolean algebra
Ch 2 lattice & boolean algebra
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbms
 

Último

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 

Último (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Ch 1-final-file organization from korth

  • 1. Chapter 1: File Organization Database System Concepts, 6th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use
  • 2. Chapter 1: Storage and File Structure  Overview of Physical Storage Media  Magnetic Disks  RAID  Tertiary Storage  Storage Access  File Organization  Organization of Records in Files  Data-Dictionary Storage Database System Concepts - 6th Edition 10.2 ©Silberschatz, Korth and Sudarshan
  • 3. Classification of Physical Storage Media  Speed with which data can be accessed  Cost per unit of data  Reliability  data loss on power failure or system crash  physical failure of the storage device  Can differentiate storage into:  volatile storage: loses contents when power is switched off  non-volatile storage:  Contents persist even when power is switched off.  Includes secondary and tertiary storage, as well as batter-backed up main-memory. Database System Concepts - 6th Edition 10.3 ©Silberschatz, Korth and Sudarshan
  • 4. Physical Storage Media  Cache – fastest and most costly form of storage; volatile; managed by the computer system hardware.  Main memory:  fast access (10s to 100s of nanoseconds; 1 nanosecond = 10–9 seconds)  generally too small (or too expensive) to store the entire database  capacities of up to a few Gigabytes widely used currently  Capacities have gone up and per-byte costs have decreased steadily and rapidly (roughly factor of 2 every 2 to 3 years)  Volatile — contents of main memory are usually lost if a power failure or system crash occurs. Database System Concepts - 6th Edition 10.4 ©Silberschatz, Korth and Sudarshan
  • 5. Physical Storage Media (Cont.)  Flash memory  Data survives power failure  Data can be written at a location only once, but location can be erased and written to again  Can support only a limited number (10K – 1M) of write/erase cycles.  Erasing of memory has to be done to an entire bank of memory  Reads are roughly as fast as main memory  But writes are slow (few microseconds), erase is slower  Widely used in embedded devices such as digital cameras, phones, and USB keys Database System Concepts - 6th Edition 10.5 ©Silberschatz, Korth and Sudarshan
  • 6. Physical Storage Media (Cont.)  Magnetic-disk  Data is stored on spinning disk, and read/written magnetically  Primary medium for the long-term storage of data; typically stores entire database.  Data must be moved from disk to main memory for access, and written back for storage  Much slower access than main memory (more on this later)  Direct-access – possible to read data on disk in any order, unlike magnetic tape  Capacities range up to roughly 1.5 TB as of 2009  Much larger capacity and cost/byte than main memory/flash memory  Growing constantly and rapidly with technology improvements (factor of 2 to 3 every 2 years)  Survives power failures and system crashes  disk failure can destroy data, but is rare Database System Concepts - 6th Edition 10.6 ©Silberschatz, Korth and Sudarshan
  • 7. Physical Storage Media (Cont.)  Optical storage  non-volatile, data is read optically from a spinning disk using a laser  CD-ROM (700 MB) and DVD (4.7 to 17 GB) most popular forms  Write-one, read-many (WORM) optical disks used for archival storage (CD-R, DVD-R, DVD+R)  Multiple write versions also available (CD-RW, DVD-RW, DVD+RW, and DVD-RAM)  Reads and writes are slower than with magnetic disk  Juke-box systems, with large numbers of removable disks, a few drives, and a mechanism for automatic loading/unloading of disks available for storing large volumes of data Database System Concepts - 6th Edition 10.7 ©Silberschatz, Korth and Sudarshan
  • 8. Physical Storage Media (Cont.)  Magnetic Tape storage  non-volatile, used primarily for BACKUP (to recover from disk failure), and for ARCHIVAL DATA.  sequential-access – much slower than disk  very high capacity (40 to 300 GB tapes available)  tape can be removed from drive  storage costs much cheaper than disk, but drives are expensive  Tape jukeboxes available for storing massive amounts of data  hundreds of terabytes (1 terabyte = 109 bytes) to even multiple petabytes (1 petabyte = 1012 bytes) Database System Concepts - 6th Edition 10.8 ©Silberschatz, Korth and Sudarshan
  • 9. Storage Hierarchy Database System Concepts - 6th Edition 10.9 ©Silberschatz, Korth and Sudarshan
  • 10. Storage Hierarchy (Cont.)  Primary storage: Fastest media but volatile (cache, MM).  Secondary storage: next level in hierarchy, non-volatile, moderately fast access time  also called on-line storage  Online data storage refers to the practice of storing electronic data with a third party service accessed via the Internet.(Printer)  E.g. flash memory, magnetic disks  Tertiary storage: lowest level in hierarchy, non-volatile, slow access time  also called off-line storage  The term used to describe any storage medium that must be inserted into a storage drive by a person before it can be accessed by the computer system is considered to be a type of off-line storage. Offline storage may also be written as off-line storage and is also called removable storage.  E.g. magnetic tape, optical storage Database System Concepts - 6th Edition 10.10 ©Silberschatz, Korth and Sudarshan
  • 11. Magnetic Hard Disk Mechanism NOTE: Diagram is schematic, and simplifies the structure of actual disk drives Database System Concepts - 6th Edition 10.11 ©Silberschatz, Korth and Sudarshan
  • 12. Single Disk Block – • a contiguous sequence of sectors from a single track • data is transferred between disk and main memory in blocks • sizes range from 512 bytes to several kilobytes: • Smaller blocks: more transfers from disk. • Larger blocks: more space wasted due to partially filled blocks • Typical block sizes today range from 4 to16 kilobytes Database System Concepts - 6th Edition 10.12 ©Silberschatz, Korth and Sudarshan
  • 13. Magnetic Disks  Read-write head  Positioned very close to the platter surface (almost touching it)  Reads or writes magnetically encoded information.  Surface of platter divided into circular tracks  Over 50K-100K tracks per platter on typical hard disks  Each track is divided into sectors.  A sector is the smallest unit of data that can be read or written.  Sector size typically 512 bytes  Typical sectors per track: 500 to 1000 (on inner tracks) to 1000 to 2000 (on outer tracks)  To read/write a sector  disk arm swings to position head on right track  platter spins continually; data is read/written as sector passes under head  Head-disk assemblies  multiple disk platters on a single spindle (1 to 5 usually)  one head per platter, mounted on a common arm.  Cylinder c consists of i th track of all the platters Database System Concepts - 6th Edition 10.13 ©Silberschatz, Korth and Sudarshan
  • 14. Disk Subsystem  Disk controller –  Interfaces between the computer system and the disk drive hardware.  multiple disks connected to a computer system through a controller  controllers functionality: checksum, bad sector remapping. Database System Concepts - 6th Edition 10.14 ©Silberschatz, Korth and Sudarshan
  • 15. RAID  RAID: Redundant Arrays of Independent Disks  Disk organization techniques that manage a large numbers of disks, providing a view of a single disk of  high capacity and high speed by using multiple disks in parallel,  high reliability by storing data redundantly, so that data can be recovered even if a disk fails Database System Concepts - 6th Edition 10.15 ©Silberschatz, Korth and Sudarshan
  • 16. About file…….. File System system provides so that users can manage information as a collection of files 11-16  A file is a named collection of related data  A file system is the logical view that an operating  A file system is often organized by grouping files into directories Database System Concepts - 6th Edition 10.16 ©Silberschatz, Korth and Sudarshan
  • 17. Properties: Fast, expensive, volatile, small - type: disks, tapes - properties: Slow , cheap, stable, large 17 Computer Architecture Main Memory (RAM) data transfer Secondary Storage Data is manipulated here Data is stored here Database System Concepts - 6th Edition 10.17 ©Silberschatz, Korth and Sudarshan
  • 18. : Main memory Expensive – compared to secondary and tertiary storage Fast – in memory operations are fast Volatile – not possible to save data from one run to its next Used for storing current data Secondary storage (hard disk) Less expensive – compared to main memory Slower – compared to main memory, faster compared to tapes Persistent – data from one run can be saved to the disk to be used in the next run Used for storing the database Tertiary storage (tapes) Cheapest Slowest – sequential data access Used for data archives Database System Concepts - 6th Edition 10.18 ©Silberschatz, Korth and Sudarshan
  • 19. File systems and databases • file: sequence of bytes stored on a computer : A collection of records or documents dealing with one organization, person, area or subject. • file system: software that provides hierarchical storage and organization of files, usually on a single computer • Database: integrated collection of logically related records – data is organized and structured for efficient systematic access . • Database system: software that provides efficient access to information in a database Database System Concepts - 6th Edition 10.19 ©Silberschatz, Korth and Sudarshan
  • 20. Physical Files and Logical Files • Physical file: • A collection of bytes stored on a disk or tape. Physical files hold the actual data of a database file HOW: Data and records stored on physical device and how the operation are made possible. • Logical file: An “interface" that allows the application programs to access the physical file. WHAT: Data and records stored view by logical file and what kind of operations may be performed on the file. Database System Concepts - 6th Edition 10.20 ©Silberschatz, Korth and Sudarshan
  • 21. Physical file: O.S: Logical file: It is actually a list of pointers to the physical file. The application program instruct the O.S. to find physical file named……?and then make connection by assigning a logical file to it. Application Program O.S. Secondary Storage Device Logical File Physical File Database System Concepts - 6th Edition 10.21 ©Silberschatz, Korth and Sudarshan
  • 22. Fixed-length and Variable-length Records A file can contain: Fixed-length records - A file where all the records are of the exactly same length is said to have fixed length records. Advantage : Access is fast because the computer knows where each record starts. Eg: If each record is 120 bytes long then the 1st record starts at [Start of File] + 0 bytes the 2nd record starts at [Start of File] + 120 bytes the 3rd record starts at [Start of File] + 240 bytes etc..... Disadvantage : Using Fixed length records, the records are usually larger and therefore need more storage space and are slower to transfer (load or save). Database System Concepts - 6th Edition 10.22 ©Silberschatz, Korth and Sudarshan
  • 23. Variable-length records - the length of each record varies One or more of the fields can be of differing lengths in each record, called variable length records Advantages:the records will be smaller and will need less storage space the records will load faster Disadvantages: The computer will be unable to determine where each record starts so processing the records will be slower. Database System Concepts - 6th Edition 10.23 ©Silberschatz, Korth and Sudarshan
  • 24. Database System Concepts - 6th Edition 10.24 ©Silberschatz, Korth and Sudarshan
  • 25.  . Text and Binary files  A binary file requires a specific interpretation of the bits 11-25  In a text file the bytes of data are organized as characters from the ASCII or Unicode character sets based on the information in the file Database System Concepts - 6th Edition 10.25 ©Silberschatz, Korth and Sudarshan
  • 26. File Operations  Create a file  Delete a file  Open a file  Close a file  Read data from a file  Write data to a file  Reposition the current file pointer in a file  Append data to the end of a file  Truncate a file (delete its contents)  Rename a file  Copy a file Database System Concepts - 6th Edition 10.26 ©Silberschatz, Kor1th1 a-2nd6 Sudarshan
  • 27. File Access Figure: Sequential file access Database System Concepts - 6th Edition 10.27 ©Silberschatz, Korth and Sudarshan
  • 28. File Access Figure: Direct file access Database System Concepts - 6th Edition 10.28 ©Silberschatz, Korth and Sudarshan
  • 29. 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 record size is fixed each 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.29 ©Silberschatz, Korth and Sudarshan
  • 30. Fixed-Length Records  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.30 ©Silberschatz, Korth and Sudarshan
  • 31. Deleting record 3 and compacting Database System Concepts - 6th Edition 10.31 ©Silberschatz, Korth and Sudarshan
  • 32. Deleting record 3 and moving last record Database System Concepts - 6th Edition 10.32 ©Silberschatz, Korth and Sudarshan
  • 33. 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.33 ©Silberschatz, Korth and Sudarshan
  • 34. Variable-Length Records  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.34 ©Silberschatz, Korth and Sudarshan
  • 35. Variable-Length Records: Slotted Page Structure  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.35 ©Silberschatz, Korth and Sudarshan
  • 36. 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.36 ©Silberschatz, Korth and Sudarshan
  • 37. 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.37 ©Silberschatz, Korth and Sudarshan
  • 38. 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.38 ©Silberschatz, Korth and Sudarshan
  • 39. 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 Database System Concepts - 6th Edition 10.39 ©Silberschatz, Korth and Sudarshan
  • 40. Storage Access  A database file is partitioned into fixed-length storage units called blocks. Blocks are units of both storage allocation and data transfer.  Database system seeks to minimize the number of block transfers between the disk and memory. We can reduce the number of disk accesses by keeping as many blocks as possible in main memory.  Buffer – portion of main memory available to store copies of disk blocks.  Buffer manager – subsystem responsible for allocating buffer space in main memory. Database System Concepts - 6th Edition 10.40 ©Silberschatz, Korth and Sudarshan
  • 41. Buffer Manager  Programs call on the buffer manager when they need a block from disk. 1. If the block is already in the buffer, buffer manager returns the address of the block in main memory 2. If the block is not in the buffer, the buffer manager 1. Allocates space in the buffer for the block 1. Replacing (throwing out) some other block, if required, to make space for the new block. 2. Replaced block written back to disk only if it was modified since the most recent time that it was written to/fetched from the disk. 2. Reads the block from the disk to the buffer, and returns the address of the block in main memory to requester. Database System Concepts - 6th Edition 10.41 ©Silberschatz, Korth and Sudarshan