Giter VIP home page Giter VIP logo

sql-mysteries's Introduction

SQL Murder Mystery

Illustration of a detective looking at evidence

There's been a Murder in SQL City! The SQL Murder Mystery is designed to be both a self-directed lesson to learn SQL concepts and commands and a fun game for experienced SQL users to solve an intriguing crime.

If you just want to solve the mystery, go to mystery.knightlab.com. If you're new to SQL, you may want to start at our walkthrough. It won't teach you everything about SQL, but it should teach you all that you need to solve the mystery.

What Else is Here?

Before we built the web-based version, we designed this for people to download and solve on their own computer. If you're interested in that, read on.

What you need to solve on your own computer

  • sql-murder-mystery.db: This SQLite database file contains all the data that you will be working with.
  • prompt: Depending on your experience level with SQL, find the prompt in either the prompt_experienced file or the prompt_beginner file.
  • reference: This is a crash course on SQL concepts and commands.
  • a SQLite environment of your choice: For beginners, we recommend using SQLiteStudio, which is a good graphical interface to use to inspect your data and write queries.

Getting Started

  • For SQL beginners: start with the reference, read the prompt_beginner file, then get started by installing SQLiteStudio and loading the db file. If you get stuck at any point, feel free to refer back to the reference, or file a GitHub issue so we can know where our instructions need to be improved.

  • For experienced SQL users: read the prompt_experienced file, then download the sql-murder-mystery.db file and use a SQL environment of your choice to solve the mystery. You can use the reference to refresh your memory of SQL. Try to complete the activity all within your SQL environment (without writing down notes)!

Checking the Solution

Write the following queries in your SQL environment to check whether you've found the right murderer:

INSERT INTO solution VALUES (1, "Insert the name of the person you found here");

SELECT value FROM solution;

Authors

Inspiration

This murder mystery was inspired by a crime in the neighboring Terminal City.

Copyright and License

Original code for this project is released under the MIT License.

Original text and other content is released under Creative Commons CC BY-SA 4.0.

SQL query custom web components used here were adapted from code created and released to the public domain by Zi Chong Kao, creator of Select Star SQL.

Detective image by rambleron used under Vecteezy's free license.

sql-mysteries's People

Contributors

dependabot[bot] avatar joegermuska avatar joonpark13 avatar ngugisenior avatar rnbsov avatar shedokan avatar steveespdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-mysteries's Issues

Mysql database file

It would be nice to have a database file that could be directly imported into MySQL/MariaDB

Thank you for making this game.

I found this game on CS50.
It reminded me of the time when I used to enjoy text adventure games.
As an extension of my programming studies, I wrote a program to reuse the game.
I made it on the spur of the moment, so it's not very good, but it works somehow.
I would be happy if you could give me some feedback.
Finally, I would like to thank you for publishing such a fun material.
Thank you.
https://github.com/tikuro69/SQL_Mystery_Generator

Main Thread Lock

It might be a good idea to move the queries to a web worker. Currently, the page freezes whenever a query is run

Convert PDF to Markdown or LaTeX

In order to extend, modify or translate the game, it would be nice to convert PDF prompts to Markdown or LaTeX format, to simplify the management

Solution is too easy to infer

First query is too revealing, just leave "SELECT * FROM sqlite_master", you can see trigger with response clearly hex-ed, just search for "online hex to ascii" and here it is.

Using hash would be a bit better, but still not ideal for limited range of possible inputs.

Implement in-browser SQL

The Select Star SQL site demonstrates a method for hosting a SQLite server in a web page and offering web components which are SQL consoles.

Might be cool to use those to make the SQL mysteries work without installation.

Missed Easter Egg Opportunity?

The full tables are full of some great tidbits, but I went back to check on some things at the end....

spoilerSo, we get to interview the actual murderer for a motive, at which point we find out he was hired. We get a description of the mastermind, which fits 3 different people by physical description and car until you get to event check-ins.

When I solved the case, the first thing I did was go back and see if we got to interview the mastermind. We did not interview Priestly, so we have no idea what the true motive for the murder was. This could be filled in with something like a sql-based grudge or anything you like.

Now, Red Korb, another suspect, is not ultimately a very interesting person, just a bit well-off (as expected of someone with a Tesla). However, the third suspect matching the car and physical description of the mastermind, Regina George, *is* another interesting one. Namely because she has no income information at all in the database, nor is she a get fit now member nor has any event check-ins. So I was thinking that, in addition to a motive interview for Priestly, you could have an easter egg for Regina where she is confessing to identity theft in an interview.

But regardless, I had fun :)

Proposal for internationalisation solution

Hello,
We are two students in relation with the teacher having opened the issue # 4, we want to translate the game into French. If you are interested we can start by modifying the html to make it translatable into all languages without skills (probable using of jinja2.ext.i18n). So @yestolife you could get it to have a web page in Chinese.
About our next work on the database see #4.
Do not hesitate to come back to us if you have any questions.

Can't check answer with web-based version?

I tried to solve the mystery using the web-based system mentioned in the README.md file. I solved the mystery, but (unless I am missing something) the web system only allows SELECT queries, so there is no way to do an INSERT to check your answer. If that's correct, it might be worth mentioning in README file

I love this game ❤️

Hi to all, this is not really an issue, but I really wanted to tell you guys how much I loved playing this.

Thank you very much 🙏 ❤️

encourage use of get_fit tables

Currently you don't need to access the get fit tables in order to find the solution.

spoiler alert...

The event that both witnesses attended only has one other person checkin on that day, which is the killer. If the event had a few (many?) more check-ins it might encourage digging into the interviews and therefore gym details...

Dangling SSNs in PERSON not referencing INCOME

Although SSN in PERSON is declared as foreign key to INCOME, there are some records in PERSON whose SSNs don't reference the primary key in INCOME. This is possible because SQLite does not enforce foreign keys by default.

sqlite> select count(*) from person where ssn not in (select ssn from income);
2497

This caused quite a bit of mystery when I tried to port the game to another database.

Similarly, there are 5 persons whose LICENSE_ID is not found in DRIVERS_LICENSE:

select * from person where license_id not in (select id from drivers_license);

Possible to see solution before starting mystery

It's possible to accidentally solve this without working through any of the mystery.

After the introduction.

SELECT sql 
  FROM sqlite_master
 where name = 'crime_scene_report'
Spoiler warning

I then wanted to see what other tables there were.

SELECT * FROM sqlite_master

This reveals the solution check and text. I'm not very familiar with SQLite so it may be that it's not possible to obscure this.

There is no way to check the true villain

A box to check this would be nice.
Or at least a transcript added to the DB which explains why the true villain is the true villain.

(I loved this game btw! 😄)

Alice in Wonderland Easter Egg?

Has anyone figured out a way to filter/sort the interview table to get the Alice in Wonderland Chapters/text in order to read it to make sense. Wondering if this was just random text, or if there actually is a way to query, before I figuratively and literally try to go down that rabbit hole, lol. No spoilers please if so.

Walkthrough has an example that may be inadvisable

The query

SELECT DISTINCT city 
FROM crime_scene_report 
WHERE LOWER(city) = 'sql city';

has a WHERE condition that may perform poorly generally speaking. If there was an index on crime_scene_report.city it might not be utilized due to LOWER(city), leading to bad performance due to a full table scan.

'Solution' same as another puzzle

Spoiler: Don't read if you haven't completed! Although I do appreciate the reference as someone who has played CLMystery previously as soon as I saw the name Jeremy Bowers in a list of a few 'suspects' I was fairly sure that was it.

Not as big a deal as it would only save you a step really but regardless, might be good to either remove that name or keep him there but change to a different solution.

Checking the schema spoils the answer

Issuing .schema from the sqlite prompt immediately spoils the answer by showing the trigger logic.

SQLite does not seem to have a portable hash function, but the answer could at least be obfuscated against accidental viewing using hex(); i.e. change the trigger condition to

CASE WHEN hex(new.value) = '4A657....

Solution is discoverable in a hacky way

In the second query example that is meant to discover the database structure, you can delete the WHERE clause, which prints the trigger text containing the solution values and methods of obtaining them. From there you can just execute SELECT * FROM person WHERE hex(name) = '4D6972...' to get the solution.

Perhaps it could be hidden somewhere outside the database.

ERD clarification

First of all, thanks for the great interactive SQL tutorial!

I'm reading the reference and I have a question about the tables connections.

image

Why is there no connection between income ssn and person ssn? I'm new to SQL and can't figure out is it a bug or everything is correct here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.