02 - DBMS Architecture
1730 words
9 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# 02 - DBMS Architecture ## 🎯 Learning Objectives After reading this topic, you will be able to: - Diagram the major components of a DBMS (storage manager, query processor, transaction manager) - Describe how a query flows from submission to result - Explain the role of the storage manager, buffer manager, and file...

02 - DBMS Architecture
🎯 Learning Objectives
After reading this topic, you will be able to:
- Diagram the major components of a DBMS (storage manager, query processor, transaction manager)
- Describe how a query flows from submission to result
- Explain the role of the storage manager, buffer manager, and file manager
- Differentiate between centralized, client-server, parallel, and distributed architectures
- List database system internals (parsing, optimization, evaluation)
📋 Prerequisites
- 01 - DBMS Introduction — Levels of abstraction, DDL/DML, database engine overview
📖 Core Content
2.1 Intuition: What Happens When You Run a Query?
When you type
SELECT name FROM instructor WHERE salary > 80000; and press Enter, what happens?
You see results in milliseconds. But behind the scenes, the DBMS goes through an elaborate pipeline:
(Diagram)- Parsing & Translation: SQL is parsed, validated (table/column existence), and translated to relational algebra
- Optimization: The optimizer considers multiple evaluation plans and chooses the cheapest (by I/O cost, CPU, etc.)
- Execution: The executor runs the chosen plan, calling the storage manager to read/write data
- Result: Results are formatted and returned to the user
Why This Matters: Understanding this pipeline helps you write efficient queries. A poorly written query can be 1000× slower than a good one — even if they return the same results!
2.2 The Query Processor
The query processor has three components:
Parsing and Translation
- Checks SQL syntax
- Validates that tables and columns exist
- Translates SQL into relational algebra (internal representation)
- Relational algebra is procedural — it tells the system how to execute
Optimization
The optimizer considers equivalent expressions (different relational algebra trees) and chooses the cheapest:
sqlSELECT name FROM instructor, teaches WHERE instructor.ID = teaches.ID AND teaches.year = 2018;
This could be executed as:
- Cartesian product → σ (year=2018) → σ (ID match) → π name
- σ (year=2018) on teaches → ⋈ on ID → π name
- Many other plans The optimizer estimates costs using:
- Number of I/O operations (dominant factor)
- CPU processing time
- Network communication (for distributed systems)
Key insight: The cost difference between a good plan and a bad plan can be enormous (seconds vs. hours).
Evaluation
The executor runs the chosen plan step by step:
- Performs selections, projections, joins
- May involve sorting, grouping, aggregation
- Returns result tuples to the user
2.3 The Storage Manager
The storage manager is the bridge between the query processor and the physical data. It consists of:
(Diagram)
| Component | Role |
|---|---|
| File Manager | Allocates/deallocates disk blocks; manages file structure |
| Buffer Manager | Brings data between disk and main memory (caching) |
| Index Manager | Creates and maintains indices for fast access |
Buffer Manager
The buffer manager divides main memory into pages. When data is requested:
- Check if the page is already in the buffer (cache hit)
- If not, read from disk (cache miss)
- If buffer is full, evict a page using a policy (LRU, Clock, etc.) Buffer management is critical because disk I/O is the dominant cost in database operations.
2.4 Transaction Management
A transaction is a collection of operations that performs a single logical function.
Example: Transfer $500 from account A to account B
pseudo1. Read A -- balance_A = 1000 2. Write A - 500 -- balance_A = 500 3. Read B -- balance_B = 200 4. Write B + 500 -- balance_B = 700 5. Commit
The Transaction Manager ensures ACID properties:
| Property | What It Means | How It's Achieved |
|---|---|---|
| Atomicity | All or nothing — either all operations complete or none do | Log-based recovery (undo/redo) |
| Consistency | Database remains in a valid state before and after | Integrity constraints, application code |
| Isolation | Concurrent transactions don't interfere with each other | Concurrency control (locking, timestamping) |
| Durability | Committed changes persist even after failures | Log-based recovery (redo) |
Without transaction management:
- Atomicity: Crash after step 2 but before step 4 → $500 disappears (inconsistent)
- Isolation: Two transfers from same account simultaneously → both read 1000,bothwrite500 → $1000 lost!
The Concurrency-Control Manager
Coordinates simultaneous access. Uses:
- Locking protocols (shared/exclusive locks, two-phase locking)
- Timestamp ordering (older transactions get priority)
- Optimistic methods (validate at commit time)
2.5 Database Architecture Types
(Diagram)
| Architecture | Description | Use Case |
|---|---|---|
| Centralized | Single machine, single database | Small organizations, personal DB |
| Client-Server | Multiple clients connect to one DB server | Most web applications |
| Parallel | Multiple CPUs sharing disk for throughput | Data warehousing, analytics |
| Distributed | Multiple databases at different sites connected via network | Global enterprises, fault tolerance |
| Cloud DB | Database as a service (AWS RDS, Google Cloud SQL) | Modern web apps, scalability |
2.6 Database System Internals: The Big Picture
(Diagram)
2.7 Database Administrators and Users
| Role | Responsibilities |
|---|---|
| Database Administrator (DBA) | Schema definition, storage structure, security, backup, performance tuning |
| Application Programmer | Writes application code that queries the database |
| Sophisticated User | Writes complex queries directly (analysts, data scientists) |
| Naive User | Uses application interfaces (ATMs, web forms) |
The DBA uses administrative tools to:
- Create and modify schemas
- Grant/revoke permissions
- Monitor performance
- Schedule backups
- Handle crash recovery
📐 Key Formulas / Concepts
| Component | Function |
|---|---|
| Parser | Validates SQL syntax and translates to relational algebra |
| Optimizer | Selects cheapest execution plan from equivalent alternatives |
| Executor | Runs the chosen plan and returns results |
| Storage Manager | Manages disk storage, buffering, and indexing |
| Transaction Manager | Ensures ACID properties |
| Concurrency Control | Manages simultaneous access to shared data |
| Recovery Manager | Restores database to consistent state after failures |
⚠️ Common Pitfalls
Pitfall 1: Thinking Query Optimization is Magic
The Mistake: "I don't need to worry about query performance — the optimizer fixes everything."
Why It's Wrong: Optimizers are good, but they can't fix fundamentally bad queries. A Cartesian product of million-row tables followed by a WHERE clause is always expensive. The optimizer can choose join order, but it can't invent missing indexes.
Correct: Write queries efficiently, create appropriate indexes, and understand your data distribution.
Pitfall 2: Confusing Centralized and Client-Server
The Mistake: "My laptop runs PostgreSQL, so it's client-server."
Why It's Wrong: Client-server means separate machines for client and server. If both are on the same machine, it's still a client-server architecture, but physically it's centralized. The distinction is about the architecture pattern, not the hardware.
Correct: Client-server is defined by the separation of concerns — the client handles the user interface, the server handles data management. They may or may not be on the same machine.
Pitfall 3: Underestimating Buffer Manager Impact
The Mistake: "Disk is slow, but my query only needs one table."
Why It's Wrong: Even a simple query may need to read thousands of blocks. Without good buffer management (caching), every block access is a disk I/O. With good caching, frequently used blocks stay in memory.
Correct: The buffer manager's cache hit ratio is one of the most important performance metrics for a database.
📝 Practice Questions
Q1. What are the three components of a query processor? Briefly explain each.
Answer
- Parser & Translator: Checks SQL syntax, validates table/column names, and translates SQL to relational algebra (internal representation)
- Optimizer: Generates multiple execution plans and picks the cheapest based on cost estimates (I/O operations, CPU, network)
- Executor: Runs the chosen plan step-by-step, coordinating with the storage manager to read/write data
Q2. List the ACID properties and what each ensures.
Answer
- Atomicity: Transaction completes fully or not at all (all-or-nothing)
- Consistency: Transaction brings database from one valid state to another
- Isolation: Concurrent transactions appear to run serially (no interference)
- Durability: Committed changes persist even after system failures
Q3. What does the buffer manager do? Why is it important?
AnswerThe buffer manager manages data movement between disk and main memory. It:
- Checks if requested data is already in memory (cache hit)
- Loads data from disk if not in memory (cache miss)
- Evicts pages when memory is full using policies like LRU
It's important because disk I/O is the dominant cost in database operations. Effective buffering (high cache hit rate) can make queries 10-100× faster.
Q4. Compare centralized and distributed database architectures.
Answer
| Aspect | Centralized | Distributed |
|---|---|---|
| Location | Single machine | Multiple sites |
| Data storage | Single database | Multiple databases |
| Pros | Simple management, consistent | Fault tolerance, scalability, local autonomy |
| Cons | Single point of failure, limited scalability | Complex management, network overhead, consistency challenges |
| Example | Small business system | Global banking system |
Q5. Why is the cost of a bad query plan potentially enormous?
AnswerA naive plan might:
- Read every block of every table (full table scans)
- Compute Cartesian products before filtering
- Not use available indexes
For a 10-million-row table, this could mean reading gigabytes of data from disk, taking minutes or hours. A good plan with index usage and optimal join order might take milliseconds.
Q6. What is the role of the concurrency-control manager?
AnswerThe concurrency-control manager ensures isolation by coordinating simultaneous access to data. It:
- Manages locks on data items (shared/exclusive)
- Ensures serializability (concurrent execution produces same result as some serial execution)
- Detects and resolves deadlocks
- Uses protocols like two-phase locking, timestamp ordering, or optimistic concurrency control
Without it, concurrent transactions could interfere (lost updates, dirty reads, incorrect summaries).
Q7. List three tasks performed by a Database Administrator.
Answer
- Schema definition: Creating and modifying database schemas
- Security management: Granting/revoking user privileges
- Backup and recovery: Scheduling backups, handling crash recovery
Other valid answers: Performance monitoring, storage management, user account management.
Q8. A bank transfer transaction debits ₹500 from account A and credits ₹500 to account B. After the debit but before the credit, the system crashes. What does the recovery manager do?
AnswerThe recovery manager checks the transaction log:
- It finds a
<T_start>record- It finds a
<T, A, old_value, new_value>for the debit- It does NOT find a
<T_commit>or<T_abort>recordSince the transaction didn't complete, the recovery manager performs an undo: it restores account A's balance to its original value (before the debit). This ensures atomicity — the incomplete transaction is fully rolled back.
🔗 Cross-References
- Next Topic: 03 - Relational Model
- Previous Topic: 01 - DBMS Introduction
- Related: BSCS2003 (MAD 1) — Three-tier architecture, web application design
- Related: BSCS4022 (OS) — Storage hierarchy, buffer management
- Textbook: Silberschatz, Korth, Sudarshan — Chapter 1 (Database System Architecture) Join Discord Previous01 - DBMS IntroductionNext03 - Relational Model