Database AdministrationUnit 211 min read
DBMS Architecture & Installation: Layers, Components & Setup
Unit 2 of Database Administration explores the internal structure of DBMS (three-schema architecture, layers, components), installation methods, and configuration steps for relational and NoSQL systems, with real-world examples from Nepalese banks and e-commerce platforms.
TAKEAWAYS:
- Three-schema architecture separates external, conceptual, and internal schemas to ensure data independence and modularity.
- DBMS layers (physical, logical, view) map to storage, query processing, and user interfaces, each with distinct functions.
- Installation methods differ by OS (Windows/Linux), licensing (open-source vs. commercial), and deployment (local vs. cloud).
- Configuration files (e.g.,
my.cnffor MySQL,postgresql.conf) control performance, security, and resource limits. - Real-world use: Banks like NMB use three-schema architecture to isolate customer-facing views from core ledgers, while Daraz’s logical layer optimizes product search queries.
- Exam focus: Compare architectures (e.g., Oracle vs. PostgreSQL), trace data flow through layers, and explain installation steps for a given DBMS.
1. DBMS Architecture: The Three-Schema Model
The three-schema architecture is the backbone of modern DBMS design. It decouples:
- External schemas (user-specific views),
- Conceptual schema (global logical structure),
- Internal schema (physical storage details).
classDiagram
class ExternalSchema {
+Views tailored to users/apps
+Example: Customer portal (NMB Bank)
}
class ConceptualSchema {
+Entity-Relationship model
+Example: Unified ledger (all branches)
}
class InternalSchema {
+File organization (heap, B-tree)
+Example: Disk blocks in NTC’s billing DB
}
ExternalSchema -->|Maps to| ConceptualSchema : 1:N
ConceptualSchema -->|Maps to| InternalSchema : 1:1
note for ConceptualSchema "Hides physical details\nfrom users/apps"Why it matters:
- Data independence: Change storage (e.g., switch from HDD to SSD) without altering user queries.
- Security: External schemas restrict access (e.g., a Daraz seller sees only their inventory).
- Modularity: Update one schema without breaking others (e.g., add a new field to NEPSE’s stock table).
Worked Example: NMB Bank’s Loan System
- External Schema: Loan officer sees
customer_id,loan_amount,interest_rate(no raw transaction logs). - Conceptual Schema: Links
customers,loans, andpaymentstables with foreign keys. - Internal Schema:
loanstable stored as a B-tree index oncustomer_idfor fast lookups.- Visual: See how a B-tree speeds up searches in the next section.
2. DBMS Layers: From Storage to User Interface
A DBMS is organized into three functional layers, each handling a specific role:
| Layer | Function | Example Components | Real-World Analogy |
|---|---|---|---|
| Physical | Raw data storage (files, disks, memory). | Tablespaces, data files, buffer pools. | Hard drive partitions in a PC. |
| Logical | Query processing, optimization, and transaction management. | Query parser, optimizer, executor. | Google’s search algorithm for YouTube. |
| View | User interfaces, APIs, and application programs. | SQL clients, ORMs (e.g., Django ORM), reports. | eSewa’s mobile app showing your bill history. |
Key Processes in the Logical Layer:
- Query Parsing: Converts SQL into a tree (e.g.,
SELECT * FROM orders WHERE date > '2023-01-01'→ parse tree). - Optimization: Chooses the fastest execution plan (e.g., index scan vs. full table scan).
- Execution: Fetches data from storage (physical layer).
Worked Example: Pathao’s Ride Request
- View Layer: User taps "Request Ride" in the app (SQL:
INSERT INTO rides(user_id, status) VALUES (123, 'pending')). - Logical Layer: Optimizer picks an index on
user_idto avoid scanning all rides. - Physical Layer: Data written to a tablespace on AWS RDS.
3. DBMS Components: The Moving Parts
A DBMS consists of core components that work together:
mindmap
root((DBMS Components))
StorageManager
Data files
Buffer manager
Authorization
QueryProcessor
DDL/DML compiler
Optimizer
Executor
TransactionManager
Locking
Recovery
Concurrency control
DBATools
Backup utilities
Monitoring toolsCritical Components Explained:
Storage Manager:
- Handles tablespaces (logical storage units) and data files (physical files on disk).
- Uses buffer pools (in-memory cache) to speed up reads/writes.
- Example: PostgreSQL’s
pg_tblspcdirectory stores tablespaces.
Query Processor:
- DDL/DML Compiler: Converts SQL into internal commands (e.g.,
CREATE TABLE→ metadata update). - Optimizer: Decides whether to use an index or a hash join (e.g., for Daraz’s product searches).
- Visual: See how a query executes in the next section.
- DDL/DML Compiler: Converts SQL into internal commands (e.g.,
Transaction Manager:
- Ensures ACID properties (Atomicity, Consistency, Isolation, Durability).
- Uses locks (e.g.,
SELECT ... FOR UPDATEin Ncell’s billing system) to prevent race conditions.
(Shows how the buffer pool caches data blocks in memory.)
4. Installation Methods: From Local to Cloud
Installing a DBMS depends on:
- Operating System: Windows (GUI installer) vs. Linux (CLI or package managers).
- Licensing: Open-source (PostgreSQL, MySQL) vs. commercial (Oracle, SQL Server).
- Deployment: On-premise, cloud (AWS RDS, Azure SQL), or hybrid.
Installation Steps for PostgreSQL (Linux)
# 1. Update package list
sudo apt update
# 2. Install PostgreSQL
sudo apt install postgresql postgresql-contrib
# 3. Check service status
sudo systemctl status postgresql
# 4. Connect to default user (postgres)
sudo -u postgres psql
Post-Installation Configuration:
Edit /etc/postgresql/<version>/main/postgresql.conf to:
- Set
shared_buffers(e.g.,4GBfor high-traffic sites like Daraz). - Enable remote connections (
listen_addresses = '*').
Comparison Table: Installation Methods
| Method | Steps | Use Case | Example |
|---|---|---|---|
| GUI Installer | Run .exe/.msi, follow prompts. |
Windows-based small businesses. | MySQL Installer for a local shop DB. |
| CLI (Linux) | Use apt, yum, or dnf to install. |
Linux servers (NTC’s internal DB). | sudo yum install oracle-xe. |
| Docker | Pull image (docker pull mysql), run container. |
Cloud-native apps (Khalti’s microservices). | docker run --name khalti-db mysql. |
| Cloud (AWS RDS) | Configure via AWS Console, select engine (PostgreSQL, MySQL), instance size. | Scalable apps (eSewa’s payment DB). | RDS for NEPSE’s trading system. |
5. Configuration Files: Tuning Performance
DBMS performance hinges on configuration files. Key files:
- MySQL:
/etc/mysql/my.cnfor/etc/my.cnf - PostgreSQL:
/etc/postgresql/<version>/main/postgresql.conf - Oracle:
$ORACLE_HOME/dbs/init<SID>.ora
Critical Parameters to Configure:
| Parameter | Purpose | Example Value | Real-World Use |
|---|---|---|---|
shared_buffers |
Memory for caching table/data blocks. | 4GB (for Daraz’s catalog DB). |
Reduces disk I/O for product searches. |
max_connections |
Limits simultaneous client connections. | 200 (for NMB’s online banking). |
Prevents overload during Diwali sales. |
work_mem |
Memory for sorting/hashing (e.g., ORDER BY, JOIN). |
64MB (for NTC’s billing queries). |
Speeds up complex reports. |
maintenance_work_mem |
Memory for VACUUM, CREATE INDEX, etc. |
1GB (for NEPSE’s nightly updates). |
Faster index rebuilds. |
Worked Example: Optimizing Khalti’s Payment DB
- Problem: Slow
SELECT * FROM transactions WHERE user_id = 123during peak hours. - Solution: Increase
shared_buffersto8GBand add an index onuser_id:CREATE INDEX idx_user_id ON transactions(user_id); - Result: Query time drops from 500ms → 10ms.
6. Real-World Applications
1. NMB Bank’s Loan Processing System
- Architecture: Three-schema model separates:
- External: Loan officer’s dashboard (only sees approved loans).
- Conceptual: Links
customers,loans, andpaymentstables. - Internal:
loanstable stored as a B-tree index oncustomer_id.
- Installation: Oracle Database 19c on-premise (high security, low latency).
- Configuration:
db_block_size = 8KB(optimized for Nepali character sets).
2. Daraz’s Product Catalog
- Logical Layer: Uses hash partitioning on
category_idto distribute products across servers. - Query Optimization: Optimizer chooses index scan over full table scan for searches like "laptops under Rs. 50,000".
- Cloud Deployment: PostgreSQL on AWS RDS with read replicas for global users.
3. NTC’s Billing System
- Physical Layer: Data stored in tablespaces on high-speed SSDs.
- Transaction Management: Uses row-level locking to prevent double-billing.
- Backup: Automated daily snapshots to S3 (for disaster recovery).
(Shows how customer_id is stored for fast lookups in NMB’s loan system.)
Exam Tip
Diagrams Are Your Friend:
- Draw the three-schema architecture and label each schema’s role.
- Sketch the DBMS layers with arrows showing data flow (physical → logical → view).
- Example Question: "Explain how a query like
SELECT name FROM customers WHERE city = 'Kathmandu'moves through the layers."
Compare DBMS Installations:
- Be ready to contrast GUI vs. CLI installation (steps, tools used).
- Example: "How would you install MySQL on Windows vs. Ubuntu?"
Configuration Shortcuts:
- Memorize 3 key parameters (
shared_buffers,max_connections,work_mem) and their impact. - Example: "Why might a bank increase
shared_buffersduring Diwali?"
- Memorize 3 key parameters (
Real-World Scenarios:
- Link concepts to Nepalese companies:
- Three-schema: "How does NMB isolate loan officers from raw transaction data?"
- Query Optimization: "How does Daraz’s optimizer choose between index and full scans?"
- Example Question: "Describe the internal schema for NEPSE’s stock trading database."
- Link concepts to Nepalese companies:
Common Pitfalls:
- Don’t confuse schemas and tablespaces:
- Schema = logical grouping (e.g.,
hr,finance). - Tablespace = physical storage unit.
- Schema = logical grouping (e.g.,
- ACID is not optional: Always mention transaction management in recovery questions.
- Don’t confuse schemas and tablespaces:
Final Visual Summary:
flowchart TD
A["User Query<br/>(e.g., eSewa bill check)"] --> B["View Layer<br/>(SQL Client)"]
B --> C["Logical Layer<br/>(Query Processor)"]
C --> D["Optimizer<br/>(Picks index or scan)"]
C --> E["Executor<br/>(Fetches data)"]
E --> F["Physical Layer<br/>(Tablespaces/Disks)"]
F --> G["Storage Manager<br/>(Buffer Pool)"]
G -->|"Data"| FBased on the TU BIM syllabus for Database Administration (IT276), unit 2.
Discussion
Loading…