Components of DBMS and Architecture

Unit 1CLO02

Database architecture defines how a database is structured, stored, managed, and accessed. The architecture provides different views to different users and handles the complexity of physical storage while presenting a simple logical view. Understanding this layered architecture and the components of DBMS is fundamental to designing scalable, maintainable database systems.

The Basics

A database system is divided into modules that deal with different responsibilities. The overall system structure consists of various components that interact to provide the database services.

Three-Schema Architecture (ANSI-SPARC)

Three Level Schema Architecture

Levels of Abstraction

The three-schema architecture separates user applications from the physical database through three levels of abstraction:

  1. EXTERNAL LEVEL (View Level):
    • Highest level of abstraction
    • Describes WHAT data is seen by individual users
    • Multiple external schemas (views) exist
    • Each view describes the portion of database relevant to a particular user group

  2. CONCEPTUAL LEVEL (Logical Level):
    • Community view of the database
    • Describes WHAT data is stored and relationships among data
    • Single conceptual schema for entire database
    • Focus on entities, data types, relationships, constraints

  3. INTERNAL LEVEL (Physical Level):
    • Lowest level of abstraction
    • Describes HOW data is physically stored
    • Deals with: Storage structures, indexes, access paths, file organization

Data Independence

The capacity to change schema at one level without affecting schema at the next higher level.

  1. LOGICAL DATA INDEPENDENCE:
    • Ability to change conceptual schema without changing external schemas
    • Example: Adding a new table doesn't affect existing views

  2. PHYSICAL DATA INDEPENDENCE:
    • Ability to change internal schema without changing conceptual schema
    • Example: Creating an index doesn't affect queries

Technical Details

DBMS COMPONENTS:

Architecture of DBMS

DBMS Architecture

  1. STORAGE MANAGER:
    • Interface between low-level data and application programs
    • Translates DML statements to low-level file-system commands
    • Responsible for: Storing, retrieving, updating data

    Components:
    • Authorization and Integrity Manager
    • Transaction Manager
    • File Manager
    • Buffer Manager

  2. QUERY PROCESSOR:
    • Simplifies and facilitates data access

    Components:
    • DDL Interpreter: Interprets DDL statements
    • DML Compiler: Translates DML to query evaluation plan
    • Query Optimizer: Chooses lowest-cost evaluation plan
    • Query Evaluation Engine: Executes query plan

  3. DATABASE USERS:

Database Users

Query Processing

A. Naive Users: Invoke application programs (ATM users, airline booking)
B. Application Programmers: Write application programs using DML
C. Sophisticated Users: Use query tools, don't write programs (analysts)
D. Database Administrator (DBA): Central control over system

  1. DBA RESPONSIBILITIES:
    • Schema definition
    • Storage structure and access method definition
    • Schema and physical organization modification
    • Granting authorization for data access
    • Routine maintenance: Backups, performance monitoring, security

CLIENT-SERVER ARCHITECTURE:

Two-Tier Architecture:
• Client: Application program, user interface
• Server: Database system (query processing, transaction management)
• Communication via database protocols (ODBC, JDBC)

Three-Tier Architecture:
• Client: Presentation layer (browser, mobile app)
• Application Server: Business logic layer (web server, API)
• Database Server: Data layer
• Benefits: Scalability, maintainability, security

Examples

EXAMPLE 1: THREE-SCHEMA ARCHITECTURE IN ACTION

Physical Level (Internal):

  • Students table stored as heap file
  • B-tree index on StudentID
  • Data blocks of 8KB size

Logical Level (Conceptual):
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(100),
Email VARCHAR(100),
DepartmentID INT
);

View Level (External):
-- View for admissions office
CREATE VIEW AdmissionView AS
SELECT StudentID, Name, Email
FROM Students;

-- View for academic department
CREATE VIEW DepartmentView AS
SELECT S.Name, S.Email, D.DepartmentName
FROM Students S
JOIN Departments D ON S.DepartmentID = D.DepartmentID;

EXAMPLE 2: DATA INDEPENDENCE

Physical Independence:
-- Original: No index
SELECT * FROM Students WHERE LastName = 'Smith';
-- Slow: Full table scan

-- DBA creates index (physical level change)
CREATE INDEX idx_lastname ON Students(LastName);

-- Same query, now fast!
SELECT * FROM Students WHERE LastName = 'Smith';
-- Application code unchanged, but performance improved!

Logical Independence:
-- DBA adds new column (conceptual level change)
ALTER TABLE Students ADD COLUMN MiddleName VARCHAR(50);

-- Existing view still works
SELECT * FROM AdmissionView;
-- Returns same columns as before, application unaffected

EXAMPLE 3: DBMS COMPONENTS IN ACTION

User Query:
SELECT Name FROM Students WHERE GPA > 3.5;

Processing Flow:

  1. DML Compiler: Parses query, checks syntax
  2. Query Optimizer: Chooses execution plan
    • Option A: Full table scan
    • Option B: Use index on GPA
    • Chooses B (lower cost)
  3. Query Evaluation Engine: Executes plan
  4. Buffer Manager: Fetches required pages into memory
  5. File Manager: Reads data from disk
  6. Result: Returns matching records

EXAMPLE 4: THREE-TIER WEB APPLICATION

Presentation Tier (Frontend):
• React/Angular application
• Displays student list
• User clicks "View Details"

Application Tier (Backend):
• Node.js server receives request
• Validates user permissions
• Queries database
• Formats response as JSON

Database Tier:
• MySQL database
• Executes: SELECT * FROM Students WHERE StudentID = ?
• Returns data to application tier

Real-World Use

IMPLEMENTING DBMS ARCHITECTURE:

  1. Setting Up Three-Tier Application:
// Application Tier (Node.js + Express)
const express = require('express');
const mysql = require('mysql2/promise');

const app = express();

// Create connection pool (efficient connection management)
const pool = mysql.createPool({
  host: 'localhost',
  user: 'app_user',
  password: 'password',
  database: 'UniversityDB',
  waitForConnections: true,
  connectionLimit: 10
});

// API endpoint
app.get('/api/students/:id', async (req, res) => {
  try {
    const [rows] = await pool.query(
      'SELECT * FROM Students WHERE StudentID = ?',
      [req.params.id]
    );
    res.json(rows[0]);
  } catch (error) {
    res.status(500).json({ error: 'Database error' });
  }
});

app.listen(3000);
  1. Implementing Views (External Level):
-- Public view: Hide sensitive data
CREATE VIEW PublicStudentInfo AS
SELECT StudentID, Name, Major
FROM Students;
-- Email, SSN hidden

-- Department view: Show department-specific data
CREATE VIEW CSStudents AS
SELECT StudentID, Name, GPA
FROM Students
WHERE Major = 'Computer Science';

-- Grant permissions on views
GRANT SELECT ON PublicStudentInfo TO public_user;
GRANT SELECT ON CSStudents TO cs_department;
  1. Physical Independence Example:
-- Application uses this query
SELECT * FROM Orders WHERE OrderDate BETWEEN '2024-01-01' AND '2024-12-31';

-- DBA optimizes physical storage (no application changes needed)
CREATE INDEX idx_order_date ON Orders(OrderDate);
-- Or partition table by year
CREATE TABLE Orders_2024 PARTITION OF Orders
FOR VALUES FROM ('2024-01-01') TO ('2024-12-31');
  1. DBA Daily Tasks:
# Monitor database performance
mysqladmin -u root -p processlist

# Check slow queries
mysql -u root -p -e "SELECT * FROM mysql.slow_log;"

# Backup database
mysqldump -u root -p UniversityDB > backup_$(date +%Y%m%d).sql

# Monitor disk space
df -h /var/lib/mysql

# Analyze table for optimization
mysql -u root -p -e "ANALYZE TABLE Students;"
  1. Best Practices:
    • Use connection pooling (don't create connection per request)
    • Implement views for security and simplification
    • Create indexes on frequently queried columns
    • Separate read-only users from write users
    • Monitor query performance regularly
    • Document schema changes
    • Test backup and recovery procedures

For exams

IMPORTANT EXAM QUESTIONS:

  1. Explain the three-schema architecture of DBMS with a neat diagram.
    Answer: External (views), Conceptual (logical schema), Internal (physical storage). Draw diagram showing mappings.

  2. What is data independence? Distinguish between logical and physical data independence with examples.

    • Physical: Change index, file organization without affecting applications
    • Logical: Change schema without affecting views
  3. List and explain the major components of a DBMS.
    Components: Storage Manager, Query Processor, Transaction Manager, Buffer Manager, File Manager

  4. What are the responsibilities of a Database Administrator (DBA)?
    Schema definition, access control, backup/recovery, performance tuning, security management

  5. Explain client-server and three-tier database architectures with diagrams.
    Two-tier: Client ↔ Database
    Three-tier: Client ↔ Application Server ↔ Database

  6. How does the query processor work? Explain its components.
    DDL Interpreter, DML Compiler, Query Optimizer, Query Evaluation Engine

  7. Describe the different types of database users.
    Naive users, Application programmers, Sophisticated users, DBA

  8. What is the role of the buffer manager in DBMS?
    Manages memory cache, replacement policies, pin/unpin pages

  9. Explain how mappings between schema levels enable data independence.
    External/Conceptual mapping and Conceptual/Internal mapping allow changes at one level without affecting others

  10. Why is three-tier architecture preferred for web applications?
    Scalability, maintainability, security, separation of concerns

QUICK REVISION:
• External Level = User Views
• Conceptual Level = Logical Schema
• Internal Level = Physical Storage
• Physical Independence = Change storage without affecting logic
• Logical Independence = Change schema without affecting views
• DBA = Central manager of database system
• Three-tier = Client, Application Server, Database

Key points

KEY TAKEAWAYS:

✓ Three-Schema Architecture: External (views), Conceptual (logical), Internal (physical)

✓ Data independence allows changes at one level without affecting other levels

✓ Physical data independence: Change storage details without affecting applications

✓ Logical data independence: Change logical schema with minimal impact on views

✓ DBMS Components: Storage Manager, Query Processor, Transaction Manager, Buffer Manager

✓ Query processing: Parse → Optimize → Execute

✓ Database users: Naive users, Application programmers, Sophisticated users, DBA

✓ DBA responsibilities: Schema management, security, backup, performance tuning

✓ Three-tier architecture: Presentation, Application, Database tiers

✓ Benefits of architecture: Scalability, maintainability, security, flexibility

✓ Views provide security by hiding sensitive data and simplifying complex schemas

✓ Buffer manager improves performance by caching frequently accessed data in memory

REMEMBER: The layered architecture and data independence are what make modern databases flexible, maintainable, and able to evolve with changing requirements without requiring application rewrites!