SQLZOO:About

From SQLZOO
Jump to navigation Jump to search

SQLZoo includes tutorials and reference to support people learning SQL.

Zookeeper

The site is maintained by Andrew Cumming a software developer at Intelligent Growth Solutions based in Edinburgh, UK.

Terms and Conditions

None. Everyone in the world is welcome to use this site and the material on it in any way they see fit.

Academic Users

Many users are from education institutions (the material was initially developed for use at Edinburgh Napier University). I am very happy to support these users, the site works particularly well with large classes where one instructor can support a large class of learners face to face.

Advertising

I run google ads at the bottom of each page and we are showing video ads to USA users via cleanmedia.com; as I am based outside the USA I don't see these ads and so I don't have a good idea if they are intrusive - Id be happy to get feedback from users about that.

Making money is not the point of the site and so https://noads.sqlzoo.net is available for anyone to use.

Why is it called SQLzoo

The inmates of SQLzoo are the SQL engines (MySQL, Oracle, SQL Server and others). They have been tamed, caged and defanged so that members of the public can pet them or poke them or gawk at them. In the wild, these engines are dangerous, needy beasts but in the confines of SQLzoo they are relatively safe. Once you have an idea of what SQL is and how it works you should install an SQL engine on your own computer and play with the real thing.

Wiki Nature

It is based on MediaWiki and it allows users to change the content. http://www.mediawiki.org/wiki/Help:Editing_pages shows how to edit pages in "standard" media wiki.

  • Only users with the teacher role can edit pages.
    • Any teachers who can help with fixing errors or creating content are most welcome
    • Send an email (ideally from an educational address) to sqlzoo.qa@gmail.com and tell us your user name - we can add that role so that you can edit.

SQLZoo features:

  • Interactive access to several SQL engines
  • Sample databases
  • Practical exercise
  • Instant feedback on the success of the student's attempts

Data

The data used in the databases is available in a slightly odd version of SQL:

For example

Format

SQLZoo includes a number of extensions to normal Wiki text:

  • class='qu'
    • A div with class qu is interpreted as an interactive question.
    • A div.qu element should include a source.def element
      • This contains the default text that the user sees.
      • Sometime this is a useful hint and is close to the correct answer.
      • It may be empty - but users often click without changing the text before even looking at it
    • A div.qu element may include a source.ans element
      • This contains the correct SQL.
      • This is hidden from the user (but not well hidden)
      • The user's result is compared with the answers result and a score is calculated

Here is an example of a question:

==Warming up==
<div class='qu'>
[[Read the notes about this table.]] Observe the result of running a simple SQL command.
<source lang='sql' class='def'>
SELECT name, region, population FROM bbc
</source>
<source lang='sql' class='ans'>
SELECT name, region, population FROM bbc
</source>
</div>

And here is how that looks when rendered...

Warming up

Read the notes about this table. Observe the result of running a simple SQL command.

SELECT name, region, population FROM bbc
SELECT name, region, population FROM bbc

StartAt

You can include a ***startAt*** span at the top of the page. This will ensure that question numbering starts at the specified value.


<span id=startAt class=params>6</span>

respectorder

Most questions do not respect order - a query is considered correct even if the order of the student's work differs from the correct answer. You can over-ride that rule by insisting that the question respects order. Place this invisible tag in your qu tag.


<span class='params respectorder'></span>

Order must be right

Show countries beginning with D by population size.

SELECT name
  FROM world
WHERE name LIKE 'D%'
ORDER by name
SELECT name
  FROM world
WHERE name LIKE 'D%'
ORDER by population

Hints

You can include a hint. The title will be shown, if the user clicks on the text the body will be revealed:

Now the hint has been revealed

<div class='hint' title='Click here to see the hint'>Now the hint has been revealed</div>

Clear Results


<div class="lsclear">Clear your results</div>

Clear your results

Setting up a new server

Note - these are instructions for me or my heirs.

sudo apt install nginx
sudo mkdir /var/www/html/sqlzoo
sudo chown 40000036 /var/www/html/sqlzoo
cd /var/www/html/sqlzoo/
curl -O https://releases.wikimedia.org/mediawiki/1.34/mediawiki-1.34.1.tar.gz
tar xvf mediawiki-1.34.1.tar.gz
mv mediawiki-1.34.1 w
sudo mysql -u root -e 'create database sqlzoo_wiki;'
scp -C andrew@sqlzoo.net:sqlzoo_wiki.sql .
scp -r andrew@sqlzoo.net:/var/www/html/sqlzoo/sqlzoo.js .
scp -r andrew@sqlzoo.net:/var/www/html/sqlzoo/design .
sudo mysql -u root sqlzoo_wiki < sqlzoo_wiki.sql
#Wait for ages - damn those spammers
scp andrew@sqlzoo.net:/var/www/html/sqlzoo/w/LocalSettings.php w
scp andrew@sqlzoo.net:/var/www/html/sqlzoo/w/images w
sudo mysql -u root sqlzoo_wiki -e 'create user wikiuser@localhost identified by "somegreatpassword";grant all on sqlzoo_wiki.* to wikiuser@localhost;'
sudo vi /etc/nginx/sites-enabled/sqlzoo
#From https://www.thegeekstuff.com/2013/12/nginx-php-fpm/
sudo apt-get install php-fpm php-mysql
# Make sure /run/php/php7.2-fpm.sock matches the value in /etc/nginx/sites-enabled and /etc/php/7.2/fpm/pool.d/www.conf
sudo apt-get install php-mbstring
sudo apt-get install php-xml
curl -O https://gitlab.com/hydrawiki/extensions/EmbedVideo/-/archive/v2.8.0/EmbedVideo-v2.8.0.zip
unzip EmbedVideo-v2.8.0.zip
mv EmbedVideo-v2.8.0 extensions/EmbedVideo
cd ~
sudo apt install certbot
sudo certbot

MySQL server configuration

/etc/mysql/conf.d/sqlzoo.cnf

#MySQL configuration- suitable for students learning SQL
# put this in /etc/mysql/conf.d/sqlzoo.cnf
[mysqld]
# A common error is a missing or incorrect JOIN condition - setting a low value helps
# errors are discovered faster
# the cost of poorly  constructed queries is reduced
max_join_size = 1000000
# Get compile time errors rather than return incorrect result sets
sql_mode = 'ONLY_FULL_GROUP_BY,NO_ZERO_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,ANSI'


nginx configuration

/etc/nginx/sites-enabled/sqlzoo

log_format timed '$remote_addr - $remote_user [$time_local] '
      '"$request" $status $body_bytes_sent $request_time '
      '"$http_referer" "$http_user_agent"';
server {
       charset UTF-8;
       root /var/www/html/sqlzoo;
       index index.html index.php;
       server_name napier.sqlzoo.net new.sqlzoo.net;
       default_type text/html;
       access_log /var/log/nginx/sqlzoo.log timed;
       location ~ \.pl|cgi$ {
           try_files $uri =404;
           gzip off;
           fastcgi_pass  127.0.0.1:8999;
           fastcgi_index index.pl;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include fastcgi_params;
       }
   location ~ \.php$ {
       include fastcgi_params;
       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
       fastcgi_param SCRIPT_FILENAME $request_filename;
  }
       location = /sqlgo {
         include uwsgi_params;
         uwsgi_pass unix:/home/andrew/sqlzoo-engine/sqlgo.sock;
         add_header 'Access-Control-Allow-Origin' '*';
       }
       location /wiki/ {
               rewrite ^/wiki/(?<pagename>.*)$ /w/index.php;
               include /etc/nginx/fastcgi_params;
               # article path should always be passed to index.php
               fastcgi_param SCRIPT_FILENAME $document_root/w/index.php;
               fastcgi_param PATH_INFO $pagename;
               fastcgi_param QUERY_STRING $query_string;
               fastcgi_pass unix:/run/php/php7.3-fpm.sock;
       }
       location ~* wp-login.php{
               return 404;
       }
       location /w/images {
               # Separate location for images/ so .php execution won't apply
       }
       location ~ /\.ht {
               deny all;
       }
       location = / {
               rewrite ^/$ /wiki/Main_Page;
       }
}
Language:Project:Language policy English  • Deutsch