I dislike relational databases, and I really dislike SQL. The problem with both is that they are way too rigid. I want flexible and dynamic databases, I want to define a schema on the spot. I also like pipes, so a database should be able to handle pipes.
In the end this means that I have to chose between document databases (like MongoDB) or embedded key/value stores (like Berkeley DB); neither of which I really want.
So a year ago I decided to write a small database server (in Go) based on Badger.
I made it, even wrote a Dockerfile for it, and I have never used it since.
The problem was that I don’t want to access some remote server for my data; I want my data to be here, on the metal.
So I took the code, removed the networking parts, and asked Gemini to clean up the rest.
Finaly I wrote a command line interface around it and sdb was born.
sdb(1)
Usage: sdb [command] [options...]
Commands:
- ls (List all keys or subset of keys specified by prefix)
- cp (Copy key/value or set of key/values specified by prefix)
- cat (Write the value of a key to stdout)
- get (Write the value of a key to a file)
- mv (Move key/value or set of key/values specified by prefix)
- pipe (Read the value of a key from stdin)
- put (Read the value of a key from a file)
- set (Read the value of a key from arguments)
- rm (Remove key/value or set of key/values specified by prefix)
Because of SDB’s flexibility and UNIX conventions, many programs can be made around it. If you wanted to make a notes program or a calendar program, you could simply write some trivial shell script around it. Like with the system upon which it is built; I find that in systems of simplicity, elegance and utility overlap.
From the idea factory
At work a colleague and I where talking about distributed databases and how we should built one. It idea itself is pretty cool, but the implementation will likely be hard. Maybe we should do away with the notion that databases and operating systems can’t trust each other; the idea that databases should have direct I/O access is antiquated. With modern filesystems (like ZFS) operating systems do get the reliability and performance expected.