top | item 39547822

Ask HN: Are there any websites for SQL puzzle games?

157 points| novoreorx | 2 years ago

As a Python programmer, I often use Django or SQLAlchemy ORM and as a consequence, my proficiency in raw SQL remains at a basic level. However, I am keen on improving my raw SQL skills, given it's sometimes superior to ORM, and because I find SQL and relational algebra surprisingly fun to think about.

Does anyone know of websites that provide SQL puzzle games that allow users to solve problems by writing SQL and validating them? I believe this would be an engaging way to enhance my SQL skills. Your suggestions are appreciated!

46 comments

order
[+] jiehong|2 years ago|reply
Maybe less fun than others, but actually not so bad: leetcode [0]

Otherwise, in the same vein as the SQL murder mystery, you can try the Hanukkah of Data [1].

[0]: https://leetcode.com/problem-list/leetcode-curated-sql-70/

[1]: https://hanukkah.bluebird.sh

[+] saulpw|2 years ago|reply
Creator of Hanukkah of Data here! We're working on another data puzzle game that we'll be announcing shortly, to be released in a couple of months. I think games like this are a great way to exercise SQL and other data skills.
[+] NortySpock|2 years ago|reply
Others have given you excellent suggestions; I will simply offer an addition -- a side quest, if you will:

Remember that the local single-user databases SQLite and DuckDB exist, and that you can use them to wrangle data without even having to set up a separate server. You just create a database file on your machine and go from there.

[+] mrtimo|2 years ago|reply
You don't even need a database file if you use Malloy, just a .parquet file or .csv file will work. Think of a .parquet file as a python dataframe saved as a file. DuckDB combined with Malloy are a powerful combo. If you like writing SQL queries for fun, you should like writing Malloy queries even more (at least I do). If you are looking to compare timeframes, Malloy does this well: https://docs.malloydata.dev/documentation/patterns/yoy
[+] sfn42|2 years ago|reply
There's also nothing stopping you from running postgres, sql server, MySQL etc locally.
[+] arono|2 years ago|reply
I’ve had fun going through SQL Murder Mystery (https://mystery.knightlab.com/)

I even use it for hiring exercises.

[+] fbdab103|2 years ago|reply
While it was not challenging SQL, it does require paying attention to the prompt, writing the queries, and following the clues. I could easily see myself blowing it in an interviewing situation with someone staring me down. In the zero pressure environment at home, I almost tripped on the fact that the license plate clue said it "included XYZ" while I initially queried `like 'XYZ%'`
[+] newprint|2 years ago|reply
www.sql-ex.ru + the book on that site are by far the best SQL exercises I have seen. PS. I know you asking about just RAW SQL, but I highly suggest you get into understanding how particular DBMS works in depth, what plans it builds, what concurrency mechanisms it uses. Writing raw SQL will get you only so far, making those queries actually production ready is completely different ballgame and for that, you don't need to be super proficient in SQL.
[+] wanderingmind|2 years ago|reply
The connection times out to the website. Any links of same exercises and book available more generally?
[+] leifhka|2 years ago|reply
Not quite puzzles, but since someone else mentioned Schemaverse, I have made a similar but Elite inspired SQL-game called Datastar [1]. It features a simulated economy with traders and miners, and the goal is to make as much money as possible. Everything is done via SQL (or other PostgreSQL features), and the player need to make and manage a database of information about the planets and their economies.

I teach uni. couses on databases and made the game for my student to give them a more self-driven way to learn SQL.

[1] https://gitlab.com/leifhka/datastar

[+] awesomeMilou|2 years ago|reply
I'm trying this out right now, since I'm writing a database exam on thursday. Is there a way to provide feedback?

I feel like the game has a lot of potential but some stuff feels kinda painful.

Like figuring out all constants for example.

[+] BazookaMusic|2 years ago|reply
https://detective.kusto.io/

It's not SQL directly (it's the Kusto query language) which is more geared towards reading data and analytics.

I'm suggesting it however because the queries in it are also basically relational algebra (aka much of the knowledge is transferable to SQL - minus some special features like anomaly analysis), they give decently sized datasets with billions of rows and the challenges themselves were fun.

[+] uncharted9|2 years ago|reply
Thanks everyone who have commented all these sites. I wanted to brush up SQL for interviews and these will help a lot.
[+] Cheezmeister|2 years ago|reply
Thanks for asking. Had a similar issue--no avenue to practice queries intentionally, outside of solving a real-world problem with all the confounding factors that entails.

Nice options ITT.