Climb the mountain
$ git clone https://github.com/phillipjohnson/sql-koans
$ python sql-koans/src/path_to_enlightenment.py
Getting Started
Installing Python
This project requires Python to run the tests, but is compatible with both versions 2 and 3. This means if you're using Mac OS or Linux, you probably don't need to install anything. If you're using Windows, you'll need to install Python which you can do here.
Getting the koans
There are three ways to work with the koans:
git clone https://github.com/phillipjohnson/sql-koans
- Fork the project on GitHub
- Download the source (links above)
Working through the koans
You'll do all of your work on the files in src/koans
. You can edit these files with any text editor such as Notepad++, SublimeText, Atom, Visual Studio Code, etc.
When you run python sql-koans/src/path_to_enlightenment.py
and an error is encountered, you'll see the file with the problem. Open that file and locate the koan that is causing the problem (don't worry, they go in order). Each koan (except the first) has something missing represented by _____
. It's your job to fix the SQL so that the correct result set is returned, or, in some cases, the correct operation is executed.
Each koan restores the database from scratch, so you don't need to worry about making a mistake. If you get really stuck, the solutions are in src/koans/solutions
.
About the SQL used in the koans
Although there is an ANSI SQL Standard, in the real world you will use a different flavor of SQL depending on the server you use. The syntax and features in the koans are compatible with Microsoft SQL Server, PostgreSQL, SQLite, and MySQL. (Note that versions of MySQL before 8 do not support Common Table Expressions.)
The syntax to create tables differs from implementation to implementation so there are no koans to create tables. If you are interested in creating your own tables, please see the documentation for the server you are using.
About
This project was inspired by the Ruby Koans, Python Koans, Scala Koans, etc. Although SQL doesn't have a strong unit testing background, we are still able to compare expected result sets against actual result sets. Instead of fixing failing asserts, we fix SQL that doesn't return the correct results.