That Blue Square Thing

Key Guide:
This is all the syntax you need to know.

AQA Computer Science GCSE

More Complex SQL

SQL becomes a little more complex when you want to get data from multiple tables.

The key is to remember how the tables are joined together.

Airport database – a relational database with two tables

You can get experiment with this database with SQLite online.

> SQLite online

Here's the database creation code so that you can try it out in SQLite.

Text file iconAirports database code – copy and paste the code. Don't forget to use DROP TABLE demo; to remove the demo table

New for 2024, SQLite now insists you use single quotes around strings, rather than double quotes. So it wants 'aString' rather than "aString". In all of the slides below I use double quotes ("aString"), because that's almost always what I do. Anything in SQLite will need single quotes now I'm afraid. Other online tools may vary of course and in an exam you'd be find with either.

Introducing multi-table queries

The slides from class introduce the idea of using queries across multiple tables:

PDF iconMulti-table queries – slides from class

PDF iconA single slide summary

And some exercises to try using a mix of single table and multi-table queries:

PDF iconAirport database questions – questions from class

PDF iconSlides with the questions on from class

Here are those SQL syntax rules again:

PDF iconSQL syntax rules

A data problem

This is an idea I want to think about at the end of the unit:

PDF iconA data management problem