I built SQL Noir, an interactive detective game that challenges you to solve mysteries using real SQL queries. It’s fully open source, designed to give you a practical and immersive way to learn SQL while engaging with a narrative-driven mystery.
> - The "submit" box isn't clear on whether it needs the name or the suspect id for the first case
I think it's implemented to be general, they wrote what to submit in 'Objectives' section though. For me as a user, I deduced that they wanted "suspect" name, after all, this is a detective game.
One small thing which would be nice is the ability to just download the sqlite database myself so I could use my preferred application to query it, and just use the site for the brief, notes and submission.
Also a nitpick, while you say it's for "learning" SQL, I would probably expect something a little more guided, or at least some example queries, if the intention was to teach SQL. As it stands, if you don't know SQL you're probably going be completely lost as to what you should be doing. It's really cool, just not specifically as a learning tool.
A great addition to a field where there aren't many offerings: SQL Island (https://sql-island.informatik.uni-kl.de) and SQL Murder Mystery (https://mystery.knightlab.com) come to mind. The mechanism of SQL Noir is close to that of the latter, i.e., an undirected, essentially standalone adventure.
I myself am working on SQLab, a SQL game engine that allows you to augment an arbitrary base with exercises on that base to produce directed, standalone adventures: https://github.com/laowantong/sqlab.
You download a dump of the database (currently MySQL, SQLite, Postgres), and can play under any administrator interface. On the same page there's a link to the long police investigation I designed for my (French) students. If you're a teacher or researcher in the field, the principles of SQLab are explained here: https://arxiv.org/abs/2410.16120.
Great project, totally agree! Also further great projects posted here. I'll chip in here my project of an SQL Game Console that comes with a SQL Game Editor -- allowing students to build their own SQL escape game in the browser: https://eskuel.de . It's been fun trying this out in the class room (only available in German right now). Example game: https://eskuel.de/zoo/
This gives me a childhood flashback to a show called MathNet, an educational police procedural (a la Dragnet) where both investigators have holstered calculators.
Good notes indeed. I have just implemented a side by side view so that you can view 2 tabs at once. I hope this helps. Also as other users suggested you can use the notes for saving queries but you can also comment them out in the editor.
> - Saving previous SQL queries and results would be cool. I was copying results into the notes. Feel like this is important as things get more complex.
I imagined myself with my flip notepad at the crime scene taking notes every time I'd copy queries/results to the notepad section. All I needed was a hat, and then say "just the facts, ma'am" a couple of times.
Agree with all but autocomplete should either be a hidden feature or disabled by default since I think it takes away from the immersion as well forces you to recall.
Thank you for the suggestions. I have just implemented the following:
- Side by Side view to open up two different tabs at the same time
- Copy button to copy table names
Wow what a great idea, I had fun solving the cases. I think maybe a comic version would help junior programmers. The SQL editor sometimes behaves strangely and does not allow correct writing.
Thanks
The editor behaves weirdly when I try to add comments.
It's hard to explain, but you can reproduce like this:
1. Write several lines, for example:
select i.*, s.*
from interviews i
join suspects s
on s.id = i.suspect_id
2. Try to comment each line on its own by typing -- in front of each line.
-- select i.*, s.*
from interviews i
join suspects s
on s.id = i.suspect_id
-- select i.*, s.*
-- from interviews i
join suspects s
on s.id = i.suspect_id
3. As soon as you do it for "from interviews i", that line will move itself to the previous line, and the syntax highlighting will be broken
This is pretty fun, I tried the two free mysteries and was fun solving them. One nit, would be nice if the SQL editor supported comments so we can comment out old queries before running new one so as keeping a history esp if we need to run the same queries again. Good stuff :)
You should be able to add -- and comment out lines of queries. If not, this is a bug that I will investigate. Also you can use the Notes tab to store any past queries and findings.
Really cute. But I really want the ability to put the different tabs -- Brief, Workspace, Schema -- side-by-side. I know SQL and wanted to play with this, but the UX was frustrating enough to drive me away, even though it is really pretty.
+1 to this.
Remembering the schema is kind of a big barrier when you're just jumping in, and that's when you want to be able to explore at random the most.
(I also struggled with the schema because crime_scene was singular and suspects was plural!)
Something is weird in at least firefox.
Type or paste:
select \*
from crime_scene;
then TYPE so you add a comment
select \*
from crime_scene;
--
I see
select ----from----------------
but when I select the text I see what I wrote - I like the comment my text (and I was pulling in the instructions) but it renders some interesting garbage pretty fast.
This is cool! Great job! I completed the first challenge.
I guess I’m used to sql server management studio I tried running multiple queries at once and wasn’t able to. I also tried writing a comment with two dashes to keep track of the id’s and it replaced most of my query with dashes. It might have something to do with being on mobile on iOS.
I just shared this with folks, it looks incredible! I’m giving it a try myself too.
By the way, I was trying to use a bunch of one-liner SQL statements to explore the data, and it seems like the editor doesn’t handle comments very well. Is there a way to make it work better?
This is a cross-join. It is the equivalent of a nested loop in programing and almost never what you want to do in a database unless you like watching high-combination data spewing out and CPUs burning. It gives you every combination of items in each table you name.
What you want is to find something in two or more of those tables that can be linked together somehow using (very likely!) "INNER JOINS". Look into examples or tutorials of those on the internet and use what you find to work through the tables on the "investigations". Luckily, the SQL Noir site tells you exactly the steps to take in the first case. You need to find a link somehow between the crime_scene and suspects tables and then another one between the matching suspects from the suspects table and the interviews table.
Note: there is no direct easy link between the crime_scene and suspects tables. You will have to use your investigation skills to trim the suspects list down.
Great fun, thank you for building this! Was confused since submitting the confession didn't work, would make sense to ask for the name of the person no?
[+] [-] RvdV|1 year ago|reply
- The "submit" box isn't clear on whether it needs the name or the suspect id for the first case
- It would be nice to have a "copy to notes" button in the output
- It would be nice to have some docs on what functions are available / which dialect this is.
I think this very valuable, it's so much more easy to learn if you actually have a small project to work on
[+] [-] caro_kann|1 year ago|reply
I think it's implemented to be general, they wrote what to submit in 'Objectives' section though. For me as a user, I deduced that they wanted "suspect" name, after all, this is a detective game.
[+] [-] worble|1 year ago|reply
One small thing which would be nice is the ability to just download the sqlite database myself so I could use my preferred application to query it, and just use the site for the brief, notes and submission.
Also a nitpick, while you say it's for "learning" SQL, I would probably expect something a little more guided, or at least some example queries, if the intention was to teach SQL. As it stands, if you don't know SQL you're probably going be completely lost as to what you should be doing. It's really cool, just not specifically as a learning tool.
[+] [-] laowantong|1 year ago|reply
[+] [-] daluc|1 year ago|reply
[+] [-] frontalier|1 year ago|reply
[+] [-] Terr_|1 year ago|reply
https://en.m.wikipedia.org/wiki/Mathnet
[+] [-] nedrylandJP|1 year ago|reply
https://youtu.be/vNhBq3kjq_Q?t=2011
[+] [-] bhollan|1 year ago|reply
[+] [-] wbakst|1 year ago|reply
I see the beginnings of a really fun way to learn / practice / remember SQL.
A few notes:
- Would be cool if it was a single workspace (no tabs). Was constantly switching tabs back and forth.
- Saving previous SQL queries and results would be cool. I was copying results into the notes. Feel like this is important as things get more complex.
Excited to see where you take this!
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] dylan604|1 year ago|reply
I imagined myself with my flip notepad at the crime scene taking notes every time I'd copy queries/results to the notepad section. All I needed was a hat, and then say "just the facts, ma'am" a couple of times.
[+] [-] fodkodrasz|1 year ago|reply
Things that would it make more immersive:
- autocomplete
- and/or the ability to view the schema alongside the query (on a wide enough screen)
- a way to copy table and column names easily with a click (table names cannot be selected at all!)
- ability to just add more queryies under/over the already executed ones, instead of only being able to replace them.
[+] [-] tiu|1 year ago|reply
Maybe enabled on a NG+?
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] jkubicek|1 year ago|reply
[+] [-] 8mobile|1 year ago|reply
[+] [-] kaeruct|1 year ago|reply
It's hard to explain, but you can reproduce like this:
1. Write several lines, for example:
2. Try to comment each line on its own by typing -- in front of each line. 3. As soon as you do it for "from interviews i", that line will move itself to the previous line, and the syntax highlighting will be broken[+] [-] chrisBHappy|1 year ago|reply
[+] [-] doruk101|1 year ago|reply
I remember getting really into it, even going to the extreme of trying to find the most efficient one-liner solution.
Thanks for making this. I’ll be passing the torch by linking it to anyone interested in learning SQL.
[+] [-] chocks|1 year ago|reply
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] agumonkey|1 year ago|reply
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] ryanianian|1 year ago|reply
[+] [-] __float|1 year ago|reply
(I also struggled with the schema because crime_scene was singular and suspects was plural!)
[+] [-] SlackingOff123|1 year ago|reply
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] deanebarker|1 year ago|reply
[+] [-] Factory|1 year ago|reply
The results header is screwed up, there is an extra 'id' column. At least on firefox.
[+] [-] hobs|1 year ago|reply
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] yesthisiswes|1 year ago|reply
I guess I’m used to sql server management studio I tried running multiple queries at once and wasn’t able to. I also tried writing a comment with two dashes to keep track of the id’s and it replaced most of my query with dashes. It might have something to do with being on mobile on iOS.
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] haliskerbas|1 year ago|reply
By the way, I was trying to use a bunch of one-liner SQL statements to explore the data, and it seems like the editor doesn’t handle comments very well. Is there a way to make it work better?
[+] [-] chrisBHappy|1 year ago|reply
[+] [-] hinkley|1 year ago|reply
Badges for completing challenges.
Issue Closed, Won’t Fix.
Badges?? We don’t need no stinking badges!
[+] [-] hotfrost|1 year ago|reply
[+] [-] mhuffman|1 year ago|reply
This is a cross-join. It is the equivalent of a nested loop in programing and almost never what you want to do in a database unless you like watching high-combination data spewing out and CPUs burning. It gives you every combination of items in each table you name.
What you want is to find something in two or more of those tables that can be linked together somehow using (very likely!) "INNER JOINS". Look into examples or tutorials of those on the internet and use what you find to work through the tables on the "investigations". Luckily, the SQL Noir site tells you exactly the steps to take in the first case. You need to find a link somehow between the crime_scene and suspects tables and then another one between the matching suspects from the suspects table and the interviews table.
Note: there is no direct easy link between the crime_scene and suspects tables. You will have to use your investigation skills to trim the suspects list down.
[+] [-] scns|1 year ago|reply