Email the Author
You can use this page to email Chris Zetter about Build a Database Server.
About the Book
Build a Database Server will guide you through building a database from scratch. You'll start by creating an interpreter that can parse and type check SQL statements, then go on to store data and build an engine to run complex queries.
You'll gain a deep knowledge about SQL and relational databases, from the execution order queries, to techniques that databases use to join and group data efficiently. Learn about database research and compare your implementation with real databases including PostgreSQL, MySQL, SQLite and DuckDB.
A hands-on approach to learning computer science topics including creating a recursive descent parser, building a type checker and implementing iterators. You choose what language to complete the project in, so pick a language you want to learn or get more practice with.
As well as guiding you through building your database, the book has:
- A test runner with 200+ test cases and test runner to help drive your implementation and provide a safety net for refactoring your code
- Specific prompts to refactor at the end of each chapter to help you reflect on and improve your code
- A sample solution that you can refer to if you get stuck and compare your approach to
- Over 30 ideas for extensions that you can choose to add to your implementation
- A link to join a discord server to share your solution and ask for help
Who is this book for?
The book is for software engineers with any amount of experience:
- It's a great project for junior engineers to learn how to build a programming language. It explains how to parse, type check and execute SQL.
- More experienced engineers will gain a deeper understanding of databases. They will get to grow and refactor a complex project as they work through the guide.
- The most senior engineers can challenge themselves by implementing the extensions at the end of chapters and dig deeper into the database research that interests them most.
What are the system requirements?
The guide is designed for a MacOS or Linux based system. You can also use the Windows Subsystem for Linux (WSL) to run the code on Windows. You will need to have Python 3.6 or later installed to run the test suite.
What will I be building?
This is a practical book. As you go through it, you will be building a database server (also known as a Database Management System or DBMS). Your database server will store data in memory and be able to parse, type and run a variety of SQL statements including implementing SELECT with WHERE, ORDER BY, GROUP BY, LIMIT and JOIN clauses as well as running aggregate functions.
What programming language can I use?
You can use almost any programming language to complete the project, including Ruby, JavaScript, TypeScript, Python, Java and many more. Unless you are looking for a challenge, there’s a couple of features that your language should have in its standard library or installable packages: support for regular expressions to help parsing SQL and the ability to start a TCP server to communicate to clients. Pick the language you want to work in. You can use the project as an opportunity to learn a new language or explore different ways of writing code in a language you already know.
About the Author
Hi, I'm Chris Zetter. I'm a software engineer and author. My favourite thing to do is to mentor other engineers and help build their skills.
I've been working with databases throughout my whole career as a lead and principal engineer. I started building my own database system as a learning project. I love practical projects that let you 'learn by doing' and enjoyed creating my own database so much that I wanted to share it with others.