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.
Here's the database creation code so that you can try it out in SQLite.
Airports 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:
Multi-table queries – slides from class
And some exercises to try using a mix of single table and multi-table queries:
Airport database questions – questions from class
Slides with the questions on from class
Here are those SQL syntax rules again:
A data problem
This is an idea I want to think about at the end of the unit: