💾 Archived View for dioskouroi.xyz › thread › 29385432 captured on 2021-11-30 at 20:18:30. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
________________________________________________________________________________
I am a Javascript developer and I've used SQL for years but it's always been a bit of a black box. I recently learned about the SQL order of operations and the relational model and it kind of blew my mind. In the process of digesting this information I wrote my own database in Javascript which I think might help others in my same situation. The result is SQLToy.
It is a SQL database written in Javascript. It's under 500 lines of code (including comments) and has zero dependencies.
The purpose of SQLToy is not to use it as a database but to learn SQL. Instead of doing this from the "outside-in" by learning the query language you do it "inside-out" by going through the implementation of the most common SQL operators. Instead of just learning _what_ the operators do, you also learn _how_ they do it which (hopefully!) should lead to a much deeper level of understanding.
A detailed wiki walks through the code of 15 different SQL operations including SELECT, WHERE, JOINs, GROUP BY, Aggregate Functions COUNT, AVG, MAX, MIN to name a few.
The wiki can be found here:
https://github.com/weinberg/SQLToy/wiki
Feedback appreciated!
I made a key value store:
https://github.com/tinfoil-knight/tiny-redis
(easy to build compared to a SQL db) and really enjoyed the process.
Making a SQL db is on my list and your wiki seems like a great place to start.
But, I also wanted to know what books/articles/implementations did you refer to create your own?
I love this. I actually think making a tiny redis is way more ambitious than a SQL database. It looks like you have a good start!
Two articles that really opened my eyes are:
A Beginner’s Guide to the True Order of SQL Operations:
https://blog.jooq.org/a-beginners-guide-to-the-true-order-of...
Set Theory: the Method To Database Madness:
https://medium.com/basecs/set-theory-the-method-to-database-...
Why would I not just use SQLite or postgres for learning SQL?
This is great - love the detail this goes into.