Dbms by jeet goyal
Transcript of Dbms by jeet goyal
DBMS, JVP Magnetic Tapes
Optical Disk
Magnetic Disk
Flash Memory
Main Memory
Cache
Storage Device Hierarchy
Cost
Access Speed
DBMS, JVP
• Fastest• Most Costly Media• Small & is managed by System H/W• Generally is inbuilt on-chip memory• For storage of important & critical
instructions• If size of cache is increased –
- cost increased- benefits of cache is lost
DBMS, JVP
• Machine instructions are stored in main memory
• Its is quite small for storing Database
• Its Volatile i.e. data is lost on power failure or system crash
DBMS, JVP
• EEPROM
• Read is Faster
• Write is very slow & complicated
• 4-10 microsec to write, can’t be overwritten
• To overwrite, has to erase entire data of memory
• Used generally for hand-held & digital electronics devices
DBMS, JVP
• Stores the Database, data moves between Main Memory & Disk
• Size – Few GB upto 80GB
• Size of Magnetic Disk needs increases as we have requirement for larger capacity disks
• Can survive power failure & system crash, is non-volatile storage media
• Disk Failure results in loss of data stored on disk.
DBMS, JVP
• CD – holds about 640MB • DVD – holds 4.7 or 8.5GB per side to 17GB for
two-sided disk
• Data is stored optically on a disk, is read by laser• WORM-write once read many CDs & DVDs• CD-RW & DVD-RW : For multiple writes & read
• CDs are magnetic-optical storage devices that use optical means to read magnetically encoded data.
• Used for archival storages
DBMS, JVP
• Used for Backup Storage
• Cheaper & Slower Access
• Sequential-access Storage
• Not direct access like CDs
• Used for holding large backup data of large organization
DBMS, JVP
Track i
Platter
Cylinder i
Spindle
R-W Head
Disk Arm
Arm Assembly
DBMS, JVP
• Access Time :
Read Req. Issued – Actual Data Transfer Begin• Seek Time : Avg. Seek Time
Time For Repositioning the arm• Rotational Latency Time : Avg. RLT
Time waiting for sector to appear under head• A T = S T + RL T• Data Transfer Rate : rate of data read/write to disk• Mean Time To Failure (MTTF)
Amount of time on avg. we expect system to work w/o failure, measure of reliability of disk
DBMS, JVP
• Reliability of Disk : 1,00,000/100 = 1000 hours
• Disk Failure leads to loss of data
• So keep redundancy i.e. Mirroring of Disk
• MTTF of mirrored disk depends on MTTR, time to replace failed disk & restore data
• First write to one copy them to other so on power failure, blocks have complete data.
DBMS, JVP
• Parallel access to disks• Improve the transfer rate by ‘Striping’• Bit-level striping : splitting bits of each byte
across multiple disks, array of 4,8,16… disks, increase R/W at 8 times
• Block-level striping : divide data into blocks, each block in a disk.
• ith block is in (i mod n + 1)th disk, n=total no. of disks in array.
• Balances load across multiple disks so access is fast & o/p is high
DBMS, JVP
CCCC
DBMS, JVP
PP P
DBMS, JVP
P
P P P P
P
DBMS, JVP
PP P
PP
P
DBMS, JVP
• Monetary Cost of extra disk
• Performance – no. of I/O Operations
• Performance when Disk fails
• Performance to rebuild the Data
RAID 0, 1, 5 are currently in use
DBMS, JVP
• File is organized logically as a sequence of records. The records are stored in disk blocks.
Fixed Length RecordsVariable Length Records
DBMS, JVP
• Deposit = record
acc_no:char(10);
br_nm:char(22);
bal:real;
end
Total = 40 bytes
Acc_no
Br_nm Bal
A-104 Bombay 500
A-121 Delhi 781
A-393 Pune 900
A-129 Bombay 400
A-214 Chennai 164
R-1
R-2
R-3
R-4
R-5
DBMS, JVP
A-104 Bombay 500
A-121 Delhi 781
A-393 Pune 900
A-129 Bombay 400
A-214 Chennai 164
Header
DBMS, JVP
• Records has varying length
• Account_list : record
Br_nm:char(22);
accounts :- array(1---infinite)
acc_no:char(10);
bal:real;
end
end
DBMS, JVP
• Dis. Adv. –
- Not easy to occupy space left by deleted record
Leads to small fragments on disk
- No space for records to grow
Header has info :
- No. of records
- Free space pointer
- Size of each record block
DBMS, JVP
• Reserved Space
• List Representation– Anchor Block– Over Flow Block
DBMS, JVP
• Heap file organization
• Sequential file organization– Search Key– Insert & Deleted using Overflow Block
• Hashing file organization
• Clustering file organization
DBMS, JVP
• A database that maintains data about relations, stores information about the tables of the database.
• E.g. Name of relations
Names of Attributes
Domains & Length
Constraints
DBMS, JVP
DBMS, JVP
• Ordered Indices
• Hash Indices
Aspects :-
- Access Type : by value or range
- Access Time
- Insertion Time
- Deletion Time
- Space Overhead
DBMS, JVP
• Primary Index– Dense Index– Sparse Index
Multilevel Indices
Secondary Indices
DBMS, JVP
• Hash File Organization
- Hash Function
- Uniform Distribution
- Random Distribution
- Bucket
Bucket Overflow & Skew
Overflow Chining
• Hash Indices
• Comparison of Indexing & Hashing
DBMS, JVP