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.

PaperSL and HLHL onlyAll
Paper 1574198

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.

Question 1 · CS-00234Paper 1 · HL only · 12 marks

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.

  1. (a)

    Outline one strength of the firewall configuration for the database server.

    2 marks

  2. (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

  3. (c)

    Describe how input validation could protect the pharmacy against SQL injection.

    2 marks

  4. (d)

    Discuss the importance of regular security testing for the pharmacy.

    4 marks

Question 2 · CS-00345Paper 1 · 11 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

  1. (a)

    Identify the two foreign keys in the Loan table.

    2 marks

  2. (b)

    State the names of the members who have borrowed A River in Winter.

    1 mark

  3. (c)

    Describe the relationship between the Member and Book tables, and how the Loan table implements it.

    2 marks

  4. (d)

    Construct an SQL query that lists the titles of all books borrowed by member M03, in alphabetical order.

    3 marks

  5. (e)

    The librarian tries to delete member M03 from the Member table.

    Explain why the database might refuse this deletion.

    3 marks

Question 3 · CS-00355Paper 1 · 10 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

  1. (a)

    Identify the primary key of the Truck table.

    1 mark

  2. (b)

    Outline the relationship between Depot and Truck.

    2 marks

  3. (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

  4. (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

Question 4 · CS-00360Paper 1 · 12 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

  1. (a)

    Identify the foreign key in the Adoption table.

    1 mark

  2. (b)

    State the output of the following query.

    SQL
    SELECT Name, Breed
    FROM Animal
    WHERE Species = 'Dog' AND ArrivalDate >= '2026-04-01'
    ORDER BY Name;

    2 marks

  3. (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

  4. (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

  5. (e)

    A volunteer runs this statement to tidy the database:

    SQL
    DELETE FROM Animal WHERE Species = 'Cat';

    Explain one problem this statement causes.

    3 marks

Question 5 · CS-00361Paper 1 · 7 marks

A hospital pharmacy keeps its stock records in a relational database. The database administrator writes these six statements.

SQL
-- 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;
  1. (a)

    Outline the difference between data definition language (DDL) and data manipulation language (DML).

    2 marks

  2. (b)

    Identify whether each of the statements 1 to 6 is DDL or DML.

    3 marks

  3. (c)

    Outline one reason why the pharmacy allows only the database administrator to run DDL statements.

    2 marks

Question 6 · CS-00362Paper 1 · 6 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

  1. (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

  2. (b)

    State the output of the following query.

    SQL
    SELECT 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.

The notes on A3.3 Database programming

More questions in Databases

  1. A3.1Database fundamentals
  2. A3.2Database design
  3. A3.3Database programmingThis page
  4. A3.4Alternative databases and data warehousesHL only

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.