- Subjects
- Computer Science
- Question bank
- A3.3 Database programming
A3.3 Database programming questions for IB Computer Science
98 questions on Database programming, written by Augment in the style of IB exam papers. Six of them are below in full, to answer on paper.
- IB Computer Science
- Part of A3 Databases
- SL and HL
Questions by paper and level
SL and HL questions are for students at either level. HL only questions cover what only HL students study.
| Paper | SL and HL | HL only | All |
|---|---|---|---|
| Paper 1 | 57 | 41 | 98 |
Counted on
Questions to try
Written by Augment in the style of IB exams, not past papers. Answer them on paper, then check each one against its markscheme with a free account.
An online pharmacy lets customers search for medicines on its website. The web server sends each search to a database server. The firewall allows inbound traffic to the web server on port 443 only, and allows the web server to connect to the database server.
- (a)
Outline one strength of the firewall configuration for the database server.
2 marks
- (b)
The search box puts the customer's text directly into an SQL query. Describe how an attacker could use SQL injection against this website, and why the firewall does not stop it.
4 marks
- (c)
Describe how input validation could protect the pharmacy against SQL injection.
2 marks
- (d)
Discuss the importance of regular security testing for the pharmacy.
4 marks
A school library stores data in a relational database. Sample data from three tables is shown.
Member
MemberID | MemberName | Form |
|---|---|---|
M01 | Aisha Rahman | 11B |
M02 | Ben Carter | 12A |
M03 | Chloe Martin | 11B |
M04 | Diego Ruiz | 13C |
Book
BookID | Title | Author |
|---|---|---|
B201 | Salt and Stars | N. Achebe |
B202 | Harbour Lights | F. Moreno |
B203 | The Clockmaker | J. Lund |
B204 | A River in Winter | S. Park |
Loan
LoanID | MemberID | BookID | DateOut |
|---|---|---|---|
301 | M03 | B204 | 2026-03-02 |
302 | M01 | B201 | 2026-03-04 |
303 | M03 | B202 | 2026-03-09 |
304 | M02 | B204 | 2026-03-16 |
305 | M03 | B201 | 2026-03-20 |
- (a)
Identify the two foreign keys in the Loan table.
2 marks
- (b)
State the names of the members who have borrowed A River in Winter.
1 mark
- (c)
Describe the relationship between the Member and Book tables, and how the Loan table implements it.
2 marks
- (d)
Construct an SQL query that lists the titles of all books borrowed by member M03, in alphabetical order.
3 marks
- (e)
The librarian tries to delete member M03 from the Member table.
Explain why the database might refuse this deletion.
3 marks
A logistics company stores its depots and lorries in a relational database.
Depot
DepotID | DepotName | Phone |
|---|---|---|
D1 | Northfield | 0161 220 4410 |
D2 | Southgate | 0161 388 9021 |
D3 | Eastbank | 0161 507 3376 |
Truck
Reg | Model | Capacity_t | DepotID |
|---|---|---|---|
LK23 RTA | Volvo FH | 26 | D2 |
MN21 PQE | DAF LF | 7 | D2 |
YT22 HBW | Scania R | 18 | D1 |
WR24 KLD | Iveco S-Way | 12 | D2 |
PV20 SXC | DAF LF | 7 | D3 |
BD25 FGN | MAN TGX | 24 | D1 |
- (a)
Identify the primary key of the Truck table.
1 mark
- (b)
Outline the relationship between Depot and Truck.
2 marks
- (c)
Southgate depot changes its phone number to 0161 388 9555.
Explain why this change is simple to make and keeps the data consistent.
3 marks
- (d)
Construct an SQL query that lists the registration and model of every truck at the Southgate depot with a capacity of more than 10 tonnes, largest capacity first.
4 marks
An animal shelter records the animals it takes in and the people who adopt them. Primary keys are shown in bold.
Animal
AnimalID | Name | Species | Breed | ArrivalDate |
|---|---|---|---|---|
A01 | Biscuit | Dog | Beagle | 2026-03-02 |
A02 | Luna | Cat | Siamese | 2026-03-10 |
A03 | Pepper | Dog | Border Collie | 2026-04-01 |
A04 | Shadow | Cat | Maine Coon | 2026-04-15 |
A05 | Bramble | Rabbit | Lop | 2026-05-03 |
A06 | Bella | Dog | Boxer | 2026-05-20 |
A07 | Mochi | Cat | Bengal | 2026-06-08 |
Adoption
AdoptionID | AnimalID | AdopterName | AdoptDate |
|---|---|---|---|
1 | A02 | Priya Shah | 2026-04-02 |
2 | A01 | Tom Byrne | 2026-04-20 |
3 | A05 | Elena Ruiz | 2026-05-30 |
4 | A06 | Marcus Lee | 2026-06-11 |
5 | A04 | Tom Byrne | 2026-07-01 |
- (a)
Identify the foreign key in the Adoption table.
1 mark
- (b)
State the output of the following query.
SQLSELECT Name, Breed FROM Animal WHERE Species = 'Dog' AND ArrivalDate >= '2026-04-01' ORDER BY Name;2 marks
- (c)
Construct an SQL query that lists the name and species of every animal adopted by Tom Byrne, together with the adoption date, with the most recent adoption first.
4 marks
- (d)
The shelter takes in a Leopard tortoise called Kiko on 14 July 2026. It is given the ID A08.
Construct an SQL statement that adds this animal to the Animal table.
2 marks
- (e)
A volunteer runs this statement to tidy the database:
SQLDELETE FROM Animal WHERE Species = 'Cat';Explain one problem this statement causes.
3 marks
A hospital pharmacy keeps its stock records in a relational database. The database administrator writes these six statements.
-- Statement 1
CREATE TABLE Medicine (MedID CHAR(4) PRIMARY KEY, MedName VARCHAR(40), Stock INTEGER);
-- Statement 2
INSERT INTO Medicine VALUES ('M012', 'Amoxicillin 500 mg', 120);
-- Statement 3
ALTER TABLE Medicine ADD ExpiryDate DATE;
-- Statement 4
UPDATE Medicine SET Stock = 40 WHERE MedID = 'M012';
-- Statement 5
DROP TABLE OldStock;
-- Statement 6
DELETE FROM Medicine WHERE Stock = 0;- (a)
Outline the difference between data definition language (DDL) and data manipulation language (DML).
2 marks
- (b)
Identify whether each of the statements 1 to 6 is DDL or DML.
3 marks
- (c)
Outline one reason why the pharmacy allows only the database administrator to run DDL statements.
2 marks
A two-screen cinema stores its films and screenings in two tables. Primary keys are shown in bold.
Film
FilmID | Title | Rating | RunMins |
|---|---|---|---|
F1 | The Long Tide | 12A | 128 |
F2 | Paper Moons | PG | 95 |
F3 | Night Circuit | 15 | 141 |
F4 | Small Giants | U | 88 |
F5 | Glass Harbour | 12A | 110 |
Screening
ScreeningID | FilmID | ScreenNo | ShowDate | StartTime |
|---|---|---|---|---|
S101 | F1 | 2 | 2026-11-14 | 18:30 |
S102 | F2 | 1 | 2026-11-14 | 11:00 |
S103 | F3 | 2 | 2026-11-14 | 21:15 |
S104 | F4 | 2 | 2026-11-14 | 10:30 |
S105 | F1 | 1 | 2026-11-15 | 14:00 |
S106 | F5 | 2 | 2026-11-15 | 19:00 |
S107 | F2 | 2 | 2026-11-14 | 14:00 |
- (a)
Construct an SQL query that lists the title and start time of every film shown on screen 2 on 14 November 2026, earliest start time first.
4 marks
- (b)
State the output of the following query.
SQLSELECT DISTINCT Film.Title FROM Film INNER JOIN Screening ON Film.FilmID = Screening.FilmID WHERE Film.RunMins > 100 AND Screening.ShowDate = '2026-11-15';2 marks
Practice all 98 in Augment
Free with an account. Every question has its markscheme, and Augment keeps the ones you got wrong so you can come back to them.
More questions in Databases
- A3.1Database fundamentals
- A3.2Database design
- A3.3Database programmingThis page
- A3.4Alternative databases and data warehousesHL only
More on Database programming
- A3.3 Database programming notesWhat Database programming covers, explained, with its key terms.
- IB Computer Science question bankEvery Computer Science topic counted, and one question from each with its markscheme.
- Computer Science exam formatEach Computer Science paper, how long it is and its share of the grade.
Check your answers in Augment
A free account opens all 98 questions on Database programming with their markschemes, and keeps a record of what you have marked.