Examhaus — Achieve with confidence.

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.

StatementTopicCommand term
A3.3.1DDL vs DMLOutline
A3.3.2Queries between two tablesConstruct
A3.3.3Updating data with SQLExplain
A3.3.4 (HL)Aggregate functionsConstruct
A3.3.5 (HL)Database viewsDescribe
A3.3.6 (HL)Transactions and data integrityDescribe

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.
  • WHERE filters rows before grouping; HAVING filters 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:

StudentIDNameYearCourseID
101Aisha12CS01
102Ben12MA02
105Ella12NULL
CourseIDTitle
CS01Computer Science
MA02Mathematics

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 Student with an alias [1]
  • LEFT JOIN, not INNER JOIN, which is required to keep students with no course [1]
  • Correct ON condition matching CourseID [1]

Common mistakes that cost marks

  • Leaving out WHERE on an UPDATE or DELETE, which changes every row.
  • Putting an aggregate in WHERE. WHERE COUNT(*) > 5 is invalid; use HAVING.
  • Writing = NULL. Use IS 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