IB Computer Science A3.3: Database programming (SQL)
New IB Computer Science syllabus · first exams May 2027 · Theme A · SL & HL (A3.3.4, A3.3.5 and A3.3.6 HL only)
A3.3 is where you write SQL: defining structures, querying across two tables, updating data and, at HL, calculating with aggregate functions, creating views and controlling transactions.
| Statement | Topic | Command term |
|---|---|---|
| A3.3.1 | DDL vs DML | Outline |
| A3.3.2 | Queries between two tables | Construct |
| A3.3.3 | Updating data with SQL | Explain |
| A3.3.4 (HL) | Aggregate functions | Construct |
| A3.3.5 (HL) | Database views | Describe |
| A3.3.6 (HL) | Transactions and data integrity | Describe |
Key points
A3.3.1 Data language types
- DDL (data definition language) defines structure:
CREATE,ALTER,DROP. - DML (data manipulation language) works with the data:
SELECT,INSERT,UPDATE,DELETE.
A3.3.2 Queries between two tables
You need: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY (ASC/DESC), GROUP BY, HAVING, JOIN, LIKE with the % wildcard, and AND / OR / NOT.
- Use INNER JOIN for matching rows only, and LEFT JOIN to keep every row from the left table, even with no match.
WHEREfilters rows before grouping;HAVINGfilters groups after aggregation.
A3.3.3 Updating data
- Add rows:
INSERT INTO … VALUES … - Change rows:
UPDATE … SET … WHERE … - Remove rows:
DELETE FROM … WHERE …
Forgetting WHERE changes every row. Indexes speed up searches but slow down updates, and heavy changes fragment an index, so it may need rebuilding or reorganizing.
A3.3.4 Aggregate functions (HL only)
COUNT, SUM, AVG (listed in the guide as AVERAGE), MIN and MAX summarise grouped data for reports, usually with GROUP BY and HAVING.
A3.3.5 Views (HL only)
- Virtual views: a saved query that always shows live data.
- Materialized (snapshot) views: store a physical copy for speed.
Views hide complexity, simplify queries and improve security, because users only see the columns they need. They can be read-only or updatable.
A3.3.6 Transactions (HL only)
A transaction is an all-or-nothing group of operations, controlled with BEGIN TRANSACTION, COMMIT and ROLLBACK. It is protected by ACID:
- Atomicity: all of it happens, or none of it.
- Consistency: valid state before and after.
- Isolation: transactions don't interfere with each other.
- Durability: committed changes survive failures.
Exam-style question
Using these tables:
| StudentID | Name | Year | CourseID |
|---|---|---|---|
| 101 | Aisha | 12 | CS01 |
| 102 | Ben | 12 | MA02 |
| 105 | Ella | 12 | NULL |
| CourseID | Title |
|---|---|
| CS01 | Computer Science |
| MA02 | Mathematics |
Construct an SQL query that lists every student's Name together with the Title of their course. Students who are not enrolled on any course must still appear in the result. [4]
Mark scheme
SELECT S.Name, C.Title
FROM Student S
LEFT JOIN Course C
ON S.CourseID = C.CourseID;- Correct columns,
SELECT S.Name, C.Title[1] FROM Studentwith an alias [1]LEFT JOIN, notINNER JOIN, which is required to keep students with no course [1]- Correct
ONcondition matching CourseID [1]
Common mistakes that cost marks
- Leaving out
WHEREon an UPDATE or DELETE, which changes every row. - Putting an aggregate in
WHERE.WHERE COUNT(*) > 5is invalid; useHAVING. - Writing
= NULL. UseIS NULL. - Choosing INNER JOIN when the question says "including those with no…". That wording signals a LEFT JOIN.
Frequently asked questions
Which parts of A3.3 are HL only?
A3.3.4 (aggregate functions), A3.3.5 (views) and A3.3.6 (transactions).
Does the exact SQL syntax matter?
The guide notes that syntax may vary between database systems. Use standard SQL and be consistent.
Go further
- Practise A3.3 with instant marking on ExamHaus. → examhaus.com
- Full A3.3 presentation and question bank with mark scheme on CS Exam Ready. → csexamready.com/resources/ib-diploma
- IB CS mock exams: Paper 1 & 2, SL & HL. → examhaus.com/mock-exams
