IB Computer Science HL · Year 2 · Lesson 46

SQL languages, queries and updates

SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.

Paper 150 minutesA3.3.1 · A3.3.2 · A3.3.3
Today’s targets

What you need to be able to do

2 / 9
  • OutlineThe differences between data language types within SQL
  • ConstructQueries between two tables in SQL
  • ExplainHow SQL can be used to update data in a database
A3.3.1A3.3.2A3.3.3
Paper 1 lensMatch the depth of every response to the command term. Previously learned content can move quickly, but retrieval must still be accurate.
Retrieve

Rapid Recall Deck

3 / 9

Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.

  • What is the difference between DDL and DML?: DDL defines or changes database structures; DML retrieves or changes the data stored in those structures.
  • Which SQL clauses/commands are central to a two-table query?: SELECT, FROM, JOIN, WHERE and related filtering/ordering clauses; the syllabus also includes DISTINCT, BETWEEN, ORDER BY, GROUP BY, HAVING, LIKE, AND, OR, and NOT.
  • What does JOIN do in SQL?: It combines related rows from two tables using a relationship/condition between their columns.
  • What do LIKE and the % wildcard do?: LIKE performs pattern matching; % represents any sequence of zero or more characters in the pattern.
  • What is the difference between WHERE and HAVING?: WHERE filters rows before grouping/aggregation; HAVING filters groups after GROUP BY.
  • Which SQL commands insert, modify, and remove records?: INSERT INTO adds records, UPDATE ... SET changes existing values, and DELETE removes records.
  • Why can updating indexed columns be expensive?: The database may also need to update, rebuild, or reorganize index structures after significant changes.
A3.3.1 + A3.3.2 · Learn

Core knowledge and application

4 / 9
A3.3.1Outline

The differences between data language types within SQL

SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.

Exam moveGive a brief, focused account containing the essential points.
Required detail 1Data language types must include data definition language (DDL) and data manipulation language (DML)
Required detail 2SQL statements to define data structures or to manipulate data

Explain it without notes

Outline: The differences between data language types within SQL in the context of a relational database used for reporting and transactional updates.

  • Data language types must include data definition language (DDL) and data manipulation language (DML)
  • SQL statements to define data structures or to manipulate data
A3.3.2Construct

Queries between two tables in SQL

SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.

Exam moveProduce the required code, diagram, query, model or representation accurately.
Required detail 1Queries must include joins, relational operators, filtering, pattern matching, and ordering data
Required detail 2SQL commands: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY, GROUP BY, HAVING, ASC, DESC, JOIN, LIKE with % wildcard, AND, OR, NOT (note: Syntax may vary in different database systems)

Explain it without notes

Construct: Queries between two tables in SQL in the context of a relational database used for reporting and transactional updates.

  • Queries must include joins, relational operators, filtering, pattern matching, and ordering data
  • SQL commands: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY, GROUP BY, HAVING, ASC, DESC, JOIN, LIKE with % wildcard, AND, OR, NOT (note: Syntax may vary in different database systems)
A3.3.3 · Learn

Core knowledge and application

5 / 9
A3.3.3Explain

How SQL can be used to update data in a database

SQL defines and manipulates relational data, while transactions protect consistency when multiple changes occur.

Exam moveGive the mechanism or relationship and make the reasons/causes explicit.
Required detail 1Insert new records (INSERT INTO), modify data (UPDATE SET), remove data (DELETE)
Required detail 2The performance implications of updating data in indexed columns, and how indexes might need to be rebuilt or reorganized following significant data modifications

Explain it without notes

Explain: How SQL can be used to update data in a database in the context of a relational database used for reporting and transactional updates.

  • Insert new records (INSERT INTO), modify data (UPDATE SET), remove data (DELETE)
  • The performance implications of updating data in indexed columns, and how indexes might need to be rebuilt or reorganized following significant data modifications
Worked example · A3.3.1–A3.3.3

SQL across two related tables

6 / 9

DDL vs DML

DDL defines structures such as tables. DML retrieves or changes stored data.

SELECT DISTINCT s.Name
FROM STUDENT AS s
JOIN ENROLLMENT AS e
  ON s.StudentID = e.StudentID
WHERE e.Score BETWEEN 80 AND 100
  AND s.Name NOT LIKE 'A%'
ORDER BY s.Name ASC;

This one query demonstrates a JOIN, filtering, BETWEEN, pattern matching with %, NOT, DISTINCT and ordering.

SELECT CourseID, COUNT(*) AS Enrolments
FROM ENROLLMENT
GROUP BY CourseID
HAVING COUNT(*) >= 5
ORDER BY Enrolments DESC;

Insert

INSERT INTO STUDENT
VALUES (17, 'Mina');

Update

UPDATE STUDENT
SET Name='Min'
WHERE StudentID=17;

Delete

DELETE FROM STUDENT
WHERE StudentID=17;
Indexed columnsLarge updates to indexed values can add maintenance cost because index structures also need to remain consistent or may require reorganization/rebuilding.
Apply

Transfer to a new scenario

7 / 9
ScenarioA relational database used for reporting and transactional updates needs a design or technical decision related to today’s topic. Explain what matters and why.
  • Data language types must include data definition language (DDL) and data manipulation language (DML)
  • SQL statements to define data structures or to manipulate data
  • Queries must include joins, relational operators, filtering, pattern matching, and ordering data
  • SQL commands: SELECT, DISTINCT, FROM, WHERE, BETWEEN, ORDER BY, GROUP BY, HAVING, ASC, DESC, JOIN, LIKE with % wildcard, AND, OR, NOT (note: Syntax may vary in different database systems)
  • Insert new records (INSERT INTO), modify data (UPDATE SET), remove data (DELETE)
  • The performance implications of updating data in indexed columns, and how indexes might need to be rebuilt or reorganized following significant data modifications
Exam lens

Paper 1 practice

8 / 9
Build the response before checking notesUse precise terminology and match the required depth.
  1. Outline: The differences between data language types within SQL in the context of a relational database used for reporting and transactional updates.
  2. Construct: Queries between two tables in SQL in the context of a relational database used for reporting and transactional updates.
  3. Explain: How SQL can be used to update data in a database in the context of a relational database used for reporting and transactional updates.
Self-checkAnswer the exact command term. For explain, include mechanism/reason; for compare, pair criteria; for discuss/evaluate/justify, build supported reasoning and a conclusion.
Homework

Finish the learning cycle

9 / 9

Exam preparation — main task

Complete targeted 2027 case-study research and cumulative Paper 1/Paper 2 practice. Record evidence and technical vocabulary you can use in extended responses.

Retrieval

Repeat today’s recall deck and revisit any item marked ‘Review again’.