Booknotes 7.
I’m writing a guide to building your own database server. Here’s what I’ve been doing:
Feedback wanted
I’m giving a small number of people access to the guide in exchange for their feedback. If you would like to read the first few chapters and start your implementation send me a message.
A book in two parts
In the interest of releasing early, I’ve split up my original plan for the guide into two parts. The first part is called ‘Running SQL’ and it’s focused on how to parse and execute SQL statements as well as going through database concepts along the way.
I’ve called the second part ‘Speed and Safety’ and it’s more focused on a few database concepts that help make queries faster (indexes and concurrent execution) and keep data safe (persistence, transactions).
I’ve made sure that the first part stands on its own. If I complete the second part it will be a free addition to anyone who has the guide.
Browsing the sample solution
The guide comes with a sample solution in Ruby and I wanted to be able to link to the commits and diffs associated with each chapter. To do this I pushed the solution to GitHub and created branches for every chapter. This means I can link to the state of the sample solution after a specific chapter and show diffs for all the code added in a chapter.
I wanted a way to update all the branches if I had to change an earlier commit. I wrote a Ruby script to help with this that I can run after rebasing the main branch.
The script has a list of commit messages and corresponding chapter names. For each chapter, it finds what should be the last commit on the branch for that chapter. It then resets the branch for that chapter to that commit. Here’s the part that finds the commit and resets the branch:
hash = `git log --grep="^#{message}" --format="%H" -n 1`.strip
`git checkout #{chapter_name}`
`git reset --hard #{hash}`
I did wonder if GitHub was the best tool to use. I looked at other git solutions that I could host myself (including Gogs, GitLab, Gitea, cgit and Stagit) but didn’t find one that had an interface that was as easy to navigate as GitHub and was worth the complexity in setting it up.
Next
There’s a few bits in the first part of the guide that need to be finished and I’ll be making changes based on any feedback.
This might be may last booknotes. When the guide is available to buy I’m going to focus on ways of promoting it that will better show off its contents. I have ideas for a few articles based on topics in the guide that I could write.