Database Fundamentals
databasedatabase-fundamentalsCore ConceptBeginner
What is a Database?
Understand databases, DBMS architectures, data persistence, and how databases differ from flat file storage.
Verified: 2026-09-30
Platforms:
nodelinux
#database#dbms#sql#storage#backend
Overview
A Database is an organized, structured collection of data stored electronically in a computer system. It is managed by a Database Management System (DBMS)—a software suite that handles data storage, querying, concurrency control, security, and crash recovery.
Databases vs Flat Files
| Feature | Flat Files (JSON, CSV, SQLite file) | Database Management System (PostgreSQL, MySQL) |
|---|---|---|
| Concurrency | File locking prevents concurrent writes | Thousands of concurrent simultaneous reads and writes |
| Integrity | Application code must manually enforce rules | Foreign keys, unique constraints, and check rules |
| Query Performance | Scans entire file into memory ($O(N)$) | B-Tree indexes and query planners find rows in $O(\log N)$ |
| Crash Safety | Partial writes corrupt files on sudden power loss | Write-Ahead Logging (WAL) and ACID transactions guarantee durability |
| Security & Roles | File permissions apply to whole file | Fine-grained column-level, table-level, and row-level access control |
The Core ACID Guarantees
Enterprise DBMS engines guarantee ACID properties for data operations:
- Atomicity: All operations within a transaction succeed together or fail completely with zero partial state left behind ("all or nothing").
- Consistency: Data must always adhere to predefined schema constraints, foreign keys, and validation rules.
- Isolation: Concurrent transactions execute independently without interfering with each other's intermediate state.
- Durability: Once a transaction is committed, changes are permanently recorded to non-volatile disk storage even if the server immediately loses power.
High-Level DBMS Architecture
Application (Backend Server)
│ SQL Query / Network Protocol
▼
┌───────────────────────────────────────┐
│ Database Management System │
│ ┌───────────────────────────────────┐ │
│ │ Connection Manager & Auth │ │
│ ├───────────────────────────────────┤ │
│ │ SQL Parser & Query Optimizer │ │
│ ├───────────────────────────────────┤ │
│ │ Execution Engine & Lock Manager │ │
│ ├───────────────────────────────────┤ │
│ │ Buffer Pool / In-Memory Cache │ │
│ ├───────────────────────────────────┤ │
│ │ Storage Engine & WAL (Disk Files) │ │
│ └───────────────────────────────────┘ │
└───────────────────────────────────────┘