DATABASE MANAGEMENT SYSTEMS/Student Engineering Notebook
Page 06·notes
STORAGE, INDEXING & B/B+ TREES—~25 MIN READ

B & B+ Trees, Multi-Level Indexing & Disk I/O Arithmetic

“Internal and leaf node order inequalities, B+ tree splits, and disk I/O calculations.”

1.The Disk I/O Bottleneck

Main memory access takes ~100 nanoseconds; reading a disk block takes ~5-10 milliseconds (50,000× slower!). An enterprise table with 10 million rows cannot be scanned sequentially on every query.

Indexing creates balanced multi-level search trees on disk that reduce search complexity from linear O(N) block scans to O(log_p N) disk block transfers. In real systems, a B+ Tree with height 3 can index billions of records while requiring only 3 disk reads to locate any record.

2.B-Tree vs B+ Tree: Why B+ Trees Rule Databases

Modern database engines (MySQL InnoDB, PostgreSQL, Oracle) exclusively use B+ Trees rather than standard B-Trees.

The Core Difference:

• Standard B-Tree: Stores keys AND actual data record pointers in both internal nodes and leaf nodes. Because record pointers take up space in internal nodes, the fanout (node order p) is small, resulting in taller trees and more disk I/Os.

• B+ Tree: Stores ONLY search keys and block pointers in internal nodes. All data record pointers reside strictly in the leaf nodes. Furthermore, all leaf nodes are connected via a doubly-linked list.

Why B+ Trees are Superior:

1. Massive Fanout: Internal nodes don't store record pointers, allowing many more keys per disk block (higher order p), yielding shallower trees.

2. Blazing Range Queries: Finding values between ₹10,000 and ₹50,000 in a B-Tree requires costly in-order tree traversal across random disk blocks. In a B+ Tree, search locates the first leaf block, then simply walks the linked list horizontally along contiguous disk blocks.

LABORATORY · INTERACTIVE SIMULATION —Concept Exploration

3. Interactive B+ Tree Order & Capacity Calculator

Enter your disk block size, key size, and pointer sizes to solve the exact algebraic inequalities for internal and leaf node orders and compute tree height and I/O costs.

Interactive Index Engineering

B+ Tree Node Order & Capacity Calculator

Solves p * P_b + (p - 1) * Key <= BlockSize and leaf inequalities.

B
B
B
B
Classic GATE Scenarios:
Internal (Non-Leaf) NodeOrder p = 29

Formula Inequality:

p · Pb + (p − 1) · K ≤ B

With values plugged in:

p · 8 + (p − 1) · 10 ≤ 512

⇒ p · 18 ≤ 522 ⇒ p = 29

Min Keys (Non-Root)⌈p/2⌉ − 1 = 14
Max Keysp − 1 = 28
Leaf Node (Data Layer)Order m = 28

Formula Inequality:

m · (K + Pr) + Pb ≤ B

With values plugged in:

m · (10 + 8) + 8 ≤ 512

⇒ m · 18 ≤ 504 ⇒ m = 28

Min Records / Leaf⌈m/2⌉ = 14
Max Records / Leafm = 28

Multi-level Index Search Performance for Table

Table Records:
Tree Height (Index Levels)4Levels to search
Disk Block I/O Cost5 I/Os4 Index + 1 Record fetch
Max Leaf Level Blocks3572Linked sequential blocks
WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: In internal nodes: (p - 1) keys and p block pointers. In leaf nodes: m (key + record pointer) pairs plus 1 next-leaf block pointer.

4. GATE Classic: B+ Tree Node Order Numerical

Problem Statement:
A database disk block is 512 bytes. Search key size is 10 bytes. Block pointer size is 8 bytes. Record pointer size is 8 bytes. Calculate the maximum order of (1) an Internal node, and (2) a Leaf node.
Block Size (B)512 BytesSearch Key (K)10 BytesBlock Pointer (Pb)8 BytesRecord Pointer (Pr)8 Bytes
Step 1: Derive Internal Node Order p

An internal node of order p contains p block pointers and (p - 1) search keys. Total size cannot exceed block size B.

p · Pb + (p - 1) · K ≤ B
↳ Result: p · 8 + (p - 1) · 10 ≤ 512 ⇒ 18p - 10 ≤ 512 ⇒ 18p ≤ 522 ⇒ p = 29
Step 2: Derive Leaf Node Order m

A leaf node stores m search key-record pointer pairs and 1 block pointer to the next leaf node.

m · (K + Pr) + Pb ≤ B
↳ Result: m · (10 + 8) + 8 ≤ 512 ⇒ 18m ≤ 504 ⇒ m = 28
Final Answer:Order of Internal node p = 29; Order of Leaf node m = 28.
STUDENT PRACTICE · CONCEPT DRILL

5. B+ Tree Indexing Quiz

Test your understanding of tree height and node split bounds.

Problem 1 · FOUNDATION

In a B+ Tree where internal nodes have maximum order p = 10, what is the minimum number of keys an internal node (other than root) must contain?

RAPID REVIEW · NOTEBOOK SUMMARY

6. 1-Minute B+ Tree Revision Card

core principle:

“B+ Tree: Keys only in internal nodes; keys + data pointers in leaves; leaves linked horizontally.”

must-remember principles:
  • •Internal order inequality: p · Pb + (p - 1) · K ≤ B.
  • •Leaf order inequality: m · (K + Pr) + Pb ≤ B.
  • •Min keys non-root internal: ⌈p/2⌉ - 1. Min keys non-root leaf: ⌈m/2⌉.
  • •Root min keys: 1 key (2 pointers). Max keys: p - 1.
  • •Disk I/Os for search = Height + 1 (Height index blocks + 1 data block).
critical exam pitfalls:
  • •In internal nodes, pointers are p and keys are p - 1; in leaf nodes, pointers and keys are both m (plus 1 next block pointer).
  • •Range queries in B+ Trees do not traverse back up to the root; they walk horizontally along the leaf pointers.
SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Primary Academic Texts
The Ubiquitous B-Tree↗by Douglas Comer (ACM Computing Surveys, 1979) · Comprehensive survey of B-Tree and B+ Tree data structures

The classic paper defining B-tree variants, split mechanics, and storage efficiency.

ACADEMIC STANDARD
Database System Concepts (10th Edition)↗by Silberschatz, Korth, Sudarshan · Chapter 14: Indexing and Hashing

Standard reference for B+ tree insertion splits, deletion borrow/merges, and order algebra.

ACADEMIC STANDARD
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Knowledge Gate · DBMS for GATE & Semester↗Instructor: Sanchit Jain · Covers: ER diagrams, normalization, SQL, transactions, concurrency control

GATE-focused numerical problem-solving with clear worked examples.

Open YouTube↗
Gate Smashers · DBMS Full Course↗Instructor: Varun Singla · Covers: Relational algebra, SQL queries, B/B+ trees, file organization

Fast conceptual coverage with step-by-step GATE numericals.

Open YouTube↗
Neso Academy · DBMS Complete Playlist↗Instructor: Neso Academy · Covers: Relational model, SQL, normalization theory, ACID properties

Systematic textbook-style explanations ideal for first-time learners.

Open YouTube↗
Ravindrababu Ravula · DBMS Lectures↗Instructor: Ravindrababu Ravula · Covers: Functional dependencies, BCNF, 3NF decomposition, transaction schedules

Deep theoretical rigor on normalization and transaction serializability.

Open YouTube↗