Back to resources
ExerciseComputer Science — Databases / SQL
Introduction to Relational Databases
27 November 2026
An exercise covering the fundamentals of relational databases: tables, primary keys, relationships and basic SQL queries.
Objectives
- Understand tables, rows and columns
- Identify a primary key and a foreign key
- Model relationships between tables
- Write simple SQL queries (
SELECT,WHERE,ORDER BY,JOIN)
Exercise
- Create a table
students (id, last_name, first_name, program). - Create a table
grades (id, student_id, subject, grade). - List the students sorted by last name.
- Show each student’s average grade using a join.