This section introduces the high-level architecture of a database management system, organized as a layered structure: REPL for user interaction, Parser for SQL interpretation, Virtual Machine for bytecode execution, B-Tree for indexing, Pager for page-based storage management, and OS Interface for system abstraction. It emphasizes modularity and data flow between layers. The project skeleton is set up using Python 3.12+ with type hints, defining a Constants module with PAGE_SIZE=4096 bytes, HEADER_LIMIT=100, and PAGE_HEADER_FORMAT='<I I' for binary headers. A stub Pager class uses struct and memoryview for low-level binary manipulation. Key design trade-offs are discussed, comparing page sizes (4KB, 8KB, 2KB) in terms of I/O performance, memory usage, and overhead. This foundation enables further development with a focus on efficiency and scalability.
Read Chapter
-
The Disk vs. Memory Dichotomy 5 min read - 4 min read