So, You Want to Build a Database (Part 1)

Sunday, January 31, 2016 - Jerry Sievert

It's silly, really: rebuilding one of the things that has been considered a "solved problem" for a number of years. But, I've always felt that in order to understand a problem fully, one must understand the problems that those who came before us were trying to solve; to take a trip through their design decisions, and to understand why they chose the solutions that they did.

Databases make up more of a part of our life than given credit for. They're a ubiquitous aspect of our lives: from the filesystems on the phones in our pockets or purses, to our email boxes. To say that we would not be where we are technologically without databases would not be a stretch. Our lives are impacted daily by access to data.

In this series of articles, we will be covering the building of a very simple database. We will be looking at storage, indexing, and querying, which covers the very basics of database operations. I chose to use Javascript, specifically Node.js, because its C-like grammar is fairly easy to follow, as well as the abundance of testing and tooling available. Any language can be used: these techniques are very basic and simple to implement in whichever environment you choose.

As the series progresses, each section will have code made available in a GitHub repository, along with documentation and tests. This code will be very basic, in order to convey concepts. While every effort will be made toward quality, this is not code that you will want to use in production but rather as a learning tool: wherever possible, simplicity will be chosen over speed or memory utilization.