Why I'm building my own database (and who writes the code)
There are certain things almost everyone wants to achieve in their life: finding a partner, building a home, becoming parents, and - of course - creating a database on your own.
From this point of view, it was only a matter of time until I would finally give in and try to build my version of it. So the question is not why, but why now.
The answer to that question is as simple as now we can.
Since I wrote my very first lines of code, data persistence and serializability have been a thing. Your program does something; it needs to store something. And of course to restore this something again at a later time, maybe at its next run.
For years I wrote code that serialized data directly into files. A database at this point in my life was something a big company would have, not a single programmer on his local machine with limited access to the internet - if any. And for most databases at this time this was true.
When I installed my first MySQL server on my PC, things changed. Everything became a row in a table. And data started to be scattered across these tables everywhere. I used Hibernate and Entity Framework and who knows what else, while the object-relational impedance mismatch never really vanished.
Over time, things got better: Firebird Embedded was the first embedded database I used. It meant I no longer had to store things in plain files, as raw binary or XML-serialized objects. In the early C++ days you gave your class something like long SerializeTo(char** buffer), wrote the bytes to disk yourself, and no one but you could ever read them back. With Firebird, even my small applications got a real database, without a server running in the background.
MongoDB was the first NoSQL database I convinced customers to use instead of an RDBMS - and it worked.
Lately I used LiteDB for projects that asked for both: locally stored data that was best served in a document style rather than in a relational model.
So why build another database?
.NET with C# used to be my primary ecosystem and it still is for some projects. These days I have started to write more code in other languages, mostly Rust. There are alternatives in Rust out there - and also some good ones, but none that exactly matched my needs (or better: my wishes).
The final decision to start and build a database on my own came when I used an AI agent to explain some limitations of one of those Rust-written alternatives. We started to dive into the details of their implementation and I suddenly realized that this was no longer a “tell me what this code does”-style of conversation, but a real discussion like I would have had with an experienced colleague.
I realized I was now able to ask every question I had about databases and their design and even discuss them, something no book could ever have done, no matter how well written it would have been. And I liked to challenge everything. “Which page size should we choose, 4096, 8192 or even 16384?” “Why B-Trees and not Skip-Lists?”, “How to build the WAL with respect to MVCC?”.
I could have answered all those questions on my own, learning a lot through the mistakes I would have made, but it would have taken me years if not decades to come to this point.
Did I really write this database then?
If the question is whether I wrote all of the code, the answer is a clear no. I freely admit, most of the lines have been written by AI. And even the lines I write are most likely rewritten by AI to match overall style and flow. There are parts that are completely AI-free, but those are rare, and I wonder if you can tell which ones they are.
If you ask, on the other hand, who made the decisions, the design, the architecture, who shaped the thing - I take credit for that one.
So what’s the goal?
At first, I just wanted a simple data store for some of my private Rust projects - but doing it the right way from the beginning. And it worked well. Most of today’s features derive from the needs of my other projects that use it. At the time of writing, trunkdb has an interface that feels natural to me:
let db = Database::open("app.trunkdb")?;
let users = db.collection::<User>("users");
let id = users.insert(ada)?;
And behind those few lines sit a page layer, a write-ahead log so a crash never leaves a broken file, indexes on nested fields and array elements, and a (static) query planner for deterministic execution plans that can be explained, and hinted to fit the needs of your data. Most recently, I introduced some basic live-query features to trunkdb. Other features have been deliberately left out. You can follow the whole decision process in the documented specs, and the current feature set as well as future plans in the changelog and roadmap.
I'm always happy to talk about trunkdb and of course other databases, to share experience and to get in touch with other database enthusiasts. The same applies if you are thinking about contributing, or are looking for mates to team up with on other exciting projects. Write to me on LinkedIn, or find me on GitHub.