Writing My Own Database From Scratch

Published at : 18 Dec 2025

First episode of the #mkown series.

In this video I write my own SQL database from scratch without using any libraries or third party dependencies. Only the standard library provided by the chosen programming language is allowed (Rust in this case). The end result is a basic ACID compliant database that can process only one transaction at a time, something similar to the first versions of SQLite from the early 2000s, but with less features (and probably much worse performance).

The goal of these videos is to provide a high level overview of how such complicated systems work internally, not explaining all the code in detail as that would require dozens of hours of content.

🌐 LINKS

Project Repository: https://github.com/antoniosarosi/mkdb

CMU Intro to Database Systems 2023:
https://youtube.com/playlist?list=PLSE8ODhjZXjbj8BMuIrRcacnQh20hmY9g&si=WNL-idIqEEMYOjcC

SQLite 2.8.1 Source Code:
https://github.com/antoniosarosi/sqlite2-btree-visualizer

✉️ CONTACT INFO

Business Email: business@antoniosarosi.io
Contact Email: sarosiantonio@gmail.com
Twitter: https://twitter.com/antoniosarosi
Instagram: https://www.instagram.com/antoniosarosi/
LinkedIn: https://www.linkedin.com/in/antoniosarosi/

🎵 MUSIC

🕖 Time Lapses

https://soundcloud.com/temporal-1/temporal-t-lpa-once-upon-a
https://www.youtube.com/watch?v=H9YSHgOD_1c

🔉 Background

https://soundcloud.com/eunoiamusicofficial/intro-falling-out
https://soundcloud.com/audialmusic/silhouette
https://soundcloud.com/cerulean-df/cerulean-skyway
https://soundcloud.com/vexaic/lifted
https://www.youtube.com/watch?v=ZkpA-O8P8TQ
https://www.youtube.com/watch?v=6NDOlXPg2BY
https://www.youtube.com/watch?v=34E4G9JW8B0
https://www.youtube.com/watch?v=HcxBHU-jR6M

📖 CHAPTERS

00:00 What is Mkown?
00:37 What Do We Know About Databases?
02:18 Research Time Lapse
02:53 Initial Ideas
03:04 Naive Storage Format
05:31 Why Binary Trees Are Not Enough For Indexes
07:46 Why B-Trees Are Better Than Binary Trees
12:21 Software Architecture
13:17 Dev Time Lapse
14:13 Project Demo
18:23 Database Internals
19:24 File System Structure
20:31 Slotted Pages
23:45 Rows, Tables And Indexes
26:50 Overflow Pages
28:30 Sophisticated BTree Balancing Algorithm
29:53 Parsing and AST (Abstract Syntax Tree)
31:54 Query Planner
34:23 K-Way External Merge Sort
36:50 Cache Replacement Algorithm
38:19 Transactions: Commit & Rollback
39:27 Network Protocol
39:56 Final Thoughts

🏷️ HASHTAGS

#programming
#computerscience