What would SQLite look like if written in Rust? — Part 0

Writing a SQLite clone from scratch in Rust

Part 1 — Understanding SQLite and Setting up CLI Application and REPL

Image for post
Image for post

Let's get the obvious out of the way, why am I doing this? Do I want to develop the next great embedded DB of the 21st century? Not really.

What I cannot create, I do not understand. — Richard Feynman

I am really doing it in order to understand better the works of it, and my goal is to document everything along the way. Wish me luck!

So how does a database work?

What format is data saved in? In our case, in memory and on disk.

When does it mode from memory to disk? How would that work exactly?

Why we only have one primary key per table? Do you know?

How does rolling back a transaction work?

How are indexes formatted? And how do they work?

When and how does a full table scan happen? Does it happen every time we issue a query? Do the indexes help? How?

What format is a prepared statement saved in?

What extra features can we add to our DB, if any?

Well, these are some of the questions I aim to answer along the way. And for that I will be relying heavily on the SQLite Architecture Documentation (https://www.sqlite.org/arch.html) and also here (https://www.sqlite.org/zipvfs/doc/trunk/www/howitworks.wiki).

Image for post
Image for post
sqlite architecture (https://www.sqlite.org/arch.html)

View on Github (pull requests are welcome)

And hey, I would be lying if I said I got the idea out of the blue, no I didn't. I got the inspiration from this other great developer called Connor, that basically did the same thing, but in C, right here (https://cstack.github.io/db_tutorial/), if you wanna check it out!

If you wanna follow this track don't forget to follow me here on Medium and also give a couple of clap!

Continue to Part 1 →

Cheers!

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store