Documentation / Guide
Issue boardGitLab source
Guide Developer guide

System architecture

A database engine translates a SQL request into a small sequence of operations on durable files. Each layer hides details from the layer above it, allowing the two owners to work through agreed C++ interfaces.

The whole engine

flowchart TB
    U([Person or course grader]) --> C[CLI and statement reader]
    subgraph SQL[SQL and frontend owner]
      C --> P[Parser: SQL text to statement AST]
      P --> B[Binder: resolve names and types]
      B --> E[Executors: DDL, DML and queries]
      M[(Catalog: schemas and constraints)] --> B
      E --> K{Validate keys and changes}
    end
    subgraph STORE[Storage and search owner]
      K --> R[Record store: rows and stable RIDs]
      K --> I[B+ tree: keys to RIDs]
      R --> BP[Bounded buffer pool]
      I --> BP
      BP --> F[Page file manager]
      F --> D[(Database files on disk)]
    end
    E --> O[Typed Result]
    O --> W[Batch CSV or interactive formatter]
    W --> U
    M --- D

The two owner boxes describe responsibility, not separate services. Everything runs inside one C++ executable. A parser does not write disk pages, and a B+ tree does not print SQL results.

Example: finding Ada

For SELECT name FROM people WHERE id = 1;, the parser recognizes a SELECT statement. The binder resolves people and its id/name columns. The planner chooses a table scan or a suitable index. The executor retrieves matching records, projects name, and returns a typed result. The formatter emits a name header, Ada, and the batch separator.

sequenceDiagram
    participant CLI
    participant SQL as Parser and binder
    participant EX as Query executor
    participant IX as Index manager
    participant RS as Record store
    participant IO as Buffer pool and files
    CLI->>SQL: SELECT name ... WHERE id = 1
    SQL->>EX: Bound select and predicate
    EX->>IX: Lookup key 1 if an index is usable
    IX->>IO: Fetch B+ tree pages
    IX-->>EX: Candidate RIDs
    EX->>RS: Fetch candidates or scan
    RS->>IO: Fetch record pages
    RS-->>EX: Typed rows
    EX-->>CLI: Result(columns, rows)
    CLI-->>CLI: Format CSV and flush @

Module boundaries

Module Receives Returns Must not own
CLI Arguments and SQL bytes User/grader output SQL semantics or raw page layout
Parser A complete SQL statement Statement AST File handles or catalog mutations
Binder/catalog AST and active database Bound columns, schema, constraints Output formatting
Executor Bound statement Typed result or error Native on-disk struct layout
Record store Schema and row/RID operations Rows and stable RIDs SQL text
Index manager Ordered key and RID Candidate RID cursor Final predicate truth or CSV
Buffer/file layer Page identifiers and guards Page contents and I/O status Row types or primary-key rules

Shared decisions before implementation

Approve CORE-001 through CORE-003 together: value encoding, schemas, stable RIDs, AST ownership, result/error types, and mutation coordination. Agree whether to adapt the optional course page-manager starter and whether to use ANTLR4 or a handwritten parser. Record these decisions in the contract MR.

The initial design uses one process, one thread, explicit memory limits, and durability after normal shutdown. WAL, crash recovery, distributed protocols, a web server and concurrent transactions are outside required scope. Optimization starts with correct page I/O and access paths.

DBS 005 · Specification v1 · Team review required for proposed interfaces.
Engine behavior is planned; implementation progress lives in GitLab.