A regular Paper 2 question: data types, primary keys, and reading or completing an SQL query on a table.
▶ Watch: IGCSE 0478: Databases and SQL (10 min)
▶ Watch first: Databases and SQL in 4 minutes
🛠️ Try it yourself: Free SQL practice playground with 10 challenges →
Original exam-style questions (19 marks) with a full mark scheme. Use it for homework, revision or a quick test.
1. Tables, records and fields
A single-table database stores data in one table. Each record (row) holds the data about one item; each field (column) holds one piece of data about every item.
Table: STUDENTS (8 records, 6 fields)
| StudentID | FirstName | Year | House | Score | Paid |
|---|---|---|---|---|---|
| S001 | Ayla | 10 | Red | 72 | TRUE |
| S002 | Ben | 11 | Blue | 85 | TRUE |
| S003 | Cem | 10 | Green | 64 | FALSE |
| S004 | Deniz | 11 | Red | 91 | TRUE |
| S005 | Elif | 10 | Blue | 58 | TRUE |
| S006 | Farid | 11 | Green | 77 | FALSE |
| S007 | Grace | 10 | Red | 83 | TRUE |
| S008 | Hasan | 11 | Blue | 69 | TRUE |
2. Data types
| Data type | Stores | Example |
|---|---|---|
| Text / alphanumeric | Letters, numbers and symbols | FirstName: “Ayla”; StudentID: “S001” |
| Character | A single character | Grade: “A” |
| Boolean | One of two values: TRUE or FALSE | Paid: TRUE |
| Integer | Whole numbers | Year: 10 |
| Real | Numbers with a decimal part | Price: 4.99 |
| Date/time | A date and/or time | DateOfBirth: 14/05/2010 |
Phone numbers and IDs with letters are stored as text, not integer: they can start with 0 and are never used in calculations.
3. Validation
Validation checks that data entered is sensible and reasonable before it is stored.
| Check | Example |
|---|---|
| Range check | Year must be between 7 and 13 |
| Length check | StudentID must be exactly 4 characters |
| Type check | Score must be an integer |
| Presence check | FirstName must not be left blank |
| Format check | StudentID must be one letter followed by three digits |
| Check digit | The last digit of an ISBN or barcode |
4. Primary keys
A primary key is a field that holds a unique value for every record, so each record can be identified. In STUDENTS, StudentID is the primary key. FirstName, Year or House would not work, because two students could share the same value.
5. SQL
Structured query language (SQL) is used to search a database.
| Keyword | Purpose | Example |
|---|---|---|
| SELECT | Which fields to show (* = all fields) | SELECT FirstName, Score |
| FROM | Which table to search | FROM STUDENTS |
| WHERE | Which records to include | WHERE Year = 11 |
| AND / OR | Combine conditions | WHERE House = ‘Red’ AND Paid = TRUE |
| ORDER BY … ASC / DESC | Sort the results in ascending or descending order | ORDER BY Score DESC |
| SUM | Add up a number field | SELECT SUM(Score) |
| COUNT | Count the records found | SELECT COUNT(*) |
Example: SELECT FirstName, Score FROM STUDENTS WHERE Year = 11 ORDER BY Score DESC; returns Deniz 91, Ben 85, Farid 77, Hasan 69.
Try it: SQL sandbox
Write a query on the STUDENTS table above, or pick an example. Supported: SELECT, FROM, WHERE, AND, OR, ORDER BY … ASC/DESC, SUM, COUNT.
6. Examiner tips
- Use the field names exactly as they appear in the table.
- Text values go in quotes in SQL; numbers and TRUE/FALSE do not.
- Phone numbers are text, not integer, because of leading zeros and spaces.
- Give a reason for a primary key: “StudentID is unique for every student”.
- Count records and fields carefully; don’t count the header row as a record.
- Check AND vs OR: AND needs both conditions to be true; OR needs at least one.
- Copy the output exactly in the order the ORDER BY gives.
7. Practice questions
Practice: answer and check instantly
Type a short answer, then press Check or Enter.
Show answer
Date/time.
Show answer
Boolean.
Show answer
Real.
Show answer
StudentID: it is unique for every student.
Show answer
3: Ayla, Deniz and Grace.
Show answer
277 = 72 + 64 + 58 + 83.
Show answer
3: Ben (85), Deniz (91) and Grace (83).
Show answer
ORDER BY (with ASC or DESC).
Exam-style questions
Not sure what a question wants? Read Command words: what the question is really asking.
9. Write an SQL query to show the FirstName and Score of all Year 11 students, highest score first. [4]
Show mark guide
SELECT FirstName, Score [1] FROM STUDENTS [1] WHERE Year = 11 [1] ORDER BY Score DESC; [1]
10. State the output of: SELECT StudentID, FirstName FROM STUDENTS WHERE Paid = FALSE OR Score < 60 [3]
Show mark guide
S003 Cem · S005 Elif · S006 Farid (Cem and Farid have not paid; Elif scored 58).
8. Topic test: predict your grade
Topic test: predict your grade
15 questions, about 10 minutes. Answer them all, then press Mark my test.
Frequently asked questions
What is a primary key?
A primary key is a field that uniquely identifies each record in a database table, such as a StudentID.
How do you write an SQL query for IGCSE?
Use SELECT to choose fields, FROM to name the table, WHERE to filter records and ORDER BY to sort, for example SELECT Name FROM Student WHERE Age greater than 15 ORDER BY Name.
What data types are used in databases?
Common data types are text or alphanumeric, character, Boolean, integer, real and date or time.
What is the difference between a field and a record?
A field is one item of data about every record, such as Surname. A record is all the data about one item, such as one student, and is stored as one row of the table.
What does ORDER BY do in SQL?
ORDER BY sorts the results of a query by a chosen field, in ascending (ASC) order by default or descending order with DESC.
What do SUM and COUNT do in SQL?
SUM adds up the values in a numeric field for the selected records. COUNT returns the number of records that match the query.
Is SQL on IGCSE Computer Science Paper 2?
Yes. Databases are Unit 9 of the 0478 syllabus and are assessed on Paper 2. You need to read and complete SQL scripts using SELECT, FROM, WHERE, ORDER BY, SUM and COUNT.