DBMS Module4 Notes
DBMS Module4 Notes
Contents
1 Discuss physical storage media in database and different types of storage
media. 3
4 Explain the hierarchy of storage systems in terms of speed, cost, and capac-
ity. 6
18 Explain the basic concept of indexing in DBMS. Discuss two basic types of
indices. 27
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 3
Registers
Cache (SRAM)
Magnetic Tape
Key insight for DBMS: Most database data lives on magnetic disks (HDD) or SSDs
because they offer a good balance of cost, capacity, and persistence. RAM is used as a buffer-
/cache to speed up frequently accessed data.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 4
Detailed Comparison:
VOLATILE (RAM/Cache)
Buffer Pool — keeps hot pages in memory
Sort areas — temporary sort during queries
Hash tables — for join operations
NON-VOLATILE (HDD/SSD)
Database files — actual table data
Index files — B+ tree, hash indexes
Log files — Write-Ahead Log (WAL)
Periodic backup
NON-VOLATILE (Tape)
Full database backups
Disaster recovery copies
Historical archival data
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 5
Structure Comparison:
R/W Head
Key takeaway: Magnetic disks are the workhorse of databases (fast, rewritable, large).
Optical disks are used for distributing software or archiving old data.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 6
Why does this matter? A DBMS tries to keep frequently used data in faster storage
(buffer pool in RAM) and pushes rarely used data to slower storage. This is called the buffer
management strategy.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 7
Component Description
Platter Circular disk coated with magnetic material (both
sides used)
Track Concentric circle on a platter surface
Sector Smallest unit on a track (typically 512 B or 4 KB)
Block/Page Multiple sectors grouped together (4–16 KB), unit
of DBMS I/O
Cylinder Same track position across all platters
R/W Head Electromagnetic device that reads/writes mag-
netic patterns
Actuator Arm Mechanical arm that moves the head to the correct
track
Spindle Motor Spins platters at constant speed (5400–15000
RPM)
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 8
# Role Explanation
1 Primary Data Storage All table data (rows and columns)
stored in disk blocks
2 Index Storage B+ Tree and hash index files reside on
disk
3 Log Files Write-Ahead Log (WAL) for crash re-
covery
4 Temporary Storage Sort runs and hash partitions during
query execution
5 System Catalog Metadata about tables, columns, con-
straints
Performance Metrics:
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 9
HDD SSD
Random IOPS 75–200 10K–100K+
Sequential Read 100–200 MB/s 500–7000 MB/s
Cost per TB $20–50 $80–200
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 10
Sector
One Sector
Track
Track
3 Track
2 Track
1 0
Spindle
Term Meaning
Platter Circular metal/glass disk; each has 2 surfaces (top
and bottom)
Surface One side of a platter; each surface has its own R/W
head
Track One concentric ring on a surface
Sector A pie-shaped slice of a track; smallest physical
unit (512 B or 4 KB)
Block / Page Group of consecutive sectors; smallest logical unit
for DBMS (4–16 KB)
Cylinder All tracks at the same radial position across all
surfaces (same arm position, no seek needed)
Surface 0
Surface 1
Cylinder i
Surface 2
Surface 3
Track i on each surface
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 11
Disk Address: Each block is identified by (Surface, Track, Sector) or using LBA
(Logical Block Addressing — a single sequential number).
DBMS organizes data on disk as: Database Files → Table Spaces → Data Pages
(blocks) + Index Pages + Log Files.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 12
Benefits of RAID 0:
# Benefit
1 Highest performance — reads/writes happen in par-
allel across N disks
2 Full capacity — 100% of all disk space is usable (no
overhead)
3 Simple design — no parity calculations, easy to im-
plement
4 High throughput — N disks give approximately N ×
the bandwidth
Drawbacks of RAID 0:
# Drawback
1 ZERO fault tolerance — if any one disk fails, ALL
data is lost
2 Reliability decreases with more disks: MTBFRAID0 =
MTBFsingle /N
3 No recovery possible — cannot rebuild data from
remaining disks
4 Not suitable for databases with valuable data
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 13
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 14
A1 A2 A1 A1
A3 A4 A2 A2
A5 A6 A3 A3
Detailed Comparison:
Key takeaway: RAID 0 gives maximum speed but zero protection. RAID 1 gives maxi-
mum protection but uses double the storage. For databases, RAID 1 (or RAID 10) is preferred
for critical data.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 15
P=A⊕B
Disk 0 FAILS!
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 16
Mathematical Justification:
• Single disk MTBF: 1,000,000 hours
• RAID 0 (2 disks): MTBF = 1,000,000/2 = 500,000 hours (worse!)
MTBF2
• RAID 1 (2 disks): MTBF = 2×MTTR (much better)
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 17
Visual Comparison:
Operation Comparison:
# Advantage
1 Very fast insertions — O(1), just add to end, no sort-
ing
2 Simple implementation — no need for complex or-
dering logic
3 Excellent for bulk loading — pour data in quickly
4 No overflow chains — unlike sequential files that need
overflow blocks
5 No reorganization cost — sequential files degrade
and need periodic cleanup
6 Efficient for full-table scans — every record visited
once regardless of order
7 Good for small tables — linear scan is fast enough
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 18
Use Heap Frequent inserts, rare targeted searches, small tables, bulk loads
Use Sequential Frequent range queries, ordered reports, few inserts
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 19
Record 2
Records grow from the end ←; header grows from the start →; free space is in the middle.
Comparison Table:
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 20
Key insight: Most real databases use variable-length records with slotted pages
because real data has VARCHAR, TEXT, and BLOB columns. The slotted page design makes
inserts/deletes efficient while handling varying sizes.
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 21
Visual Comparison:
Heap Sequential Hash Clustered
Rec 5 Rec 1 Bucket 0: Rec 2,4 Dept:CS + Emp:Alice
Performance Comparison:
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 22
Block(S1,
2: Alice,
(S2,CS)
Bob, Math)
(S3, Charlie,
(S4, CS)
Dave, Math)
(S5, Eve, CS)
Benefit: “Find all CS students” reads just 1 block instead of scanning the whole table.
Benefit: “Join Department and Employee on DeptID” requires zero extra I/O — the
joined data is already together!
Advantages Disadvantages
Fast join queries (data co- Slower inserts (find correct clus-
located) ter)
Better cache utilization Updates to cluster key are expen-
sive
Fewer disk I/O operations Queries on individual tables may
be slower
Excellent for range queries on Only one clustering order per file
cluster key
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 23
Advantages of RAID:
# Advantage Explanation
1 Improved Per- Parallel I/O across multiple disks in-
formance creases read/write throughput
2 Data Redun- Mirroring or parity ensures data sur-
dancy vives disk failure
3 High Availabil- System continues operating even after
ity a disk failure
4 Fault Tolerance Lost data can be rebuilt from mirrors
or parity
5 Scalability Add more disks to increase capacity
and speed
6 Transparency Appears as a single logical disk to
DBMS
7 Cost Effective Multiple cheap disks cheaper than one
high-end disk
8 Hot Swapping Replace a failed disk without shutting
down the system
Disadvantages:
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 24
RAID 1 — Mirroring:
Disk 0 Disk 1
A1 A1
=
A2 A2
B1 B2 Bp B3
C1 Cp C2 C3
Dp D1 D2 D3
A1 A1 A2 A2
A3 A3 A4 A4
Summary Table:
Level Technique Min Capacity Tolerance Read Write
0 Striping 2 N 0 High High
1 Mirroring 2 N/2 1 disk High Med
5 Dist. Parity 3 N −1 1 disk High Med
6 Dbl. Parity 4 N −2 2 disks High Low
10 Stripe+Mirror 4 N/2 1/pair Highest High
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 25
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 26
Recommendation: For most databases, use RAID 5 (balance of speed, safety, cost) or
RAID 10 (best speed + safety, but 50% capacity).
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 27
10 → 10 Alice
20 → 20 Bob
30 → 30 Charlie
40 → 40 Dave
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 28
Property Value
Maximum children per node m
Maximum keys per node m−1
Minimum children (non-root, internal) ⌈m/2⌉
Minimum keys (non-root) ⌈m/2⌉ − 1
Root minimum children 2 (if not a leaf)
All leaves at same level? Yes (always balanced)
Node Structure:
P0 K1 P1 K2 P2 K3 P3
40
20 60
10 30
50 70
B-Tree vs B+ Tree:
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 29
DBMS Notes
Module 4: Physical Storage, RAID & Indexing Page 30
Finding record with key 30: search index ⇒ follow pointer ⇒ direct access.
2. Sparse Index — one index entry per block (not every record). Data must be sorted.
30, Charlie
30 → 40, Dave
Finding key 20: index gives 10 (largest ≤ 20) ⇒ go to that block ⇒ scan block to find 20.
3. Multilevel Index — when the index itself is too large, build an index on the index.
Comparison Table:
DBMS Notes