How Does a Database Work?

- What format is data saved in? (in memory and on disk)
- When does it move from memory to disk?
- Why can there only be one primary key per table?
- How does rolling back a transaction work?
- How are indexes formatted?
- When and how does a full table scan happen?
- What format is a prepared statement saved in?

I’m building a clone of sqlite from scratch in C in order to understand, and I’m going to document my process as I go.

Follow along on the blog (https://cstack.github.io/db_tutorial/). I try to write at least 3 articles per month.

##########
# Roadmap
##########

- Write and retrieve records from disk [DONE]
- Retrieve records through a pager [DONE]
- Store records in a B-Tree [IN-PROGRESS]
- Support deletion
- Support `where` clauses
- Support multiple tables
- Support indexes
- Simple query planner
- Support transactions
- Begin concurrent access