Clastify logo
Subjects
Features
Review
HOT
Tutoring

A3.3 Database programming

Practice exam-style IB Computer Science questions for Database programming, aligned with the syllabus and grouped by topic.

Paper
Difficulty
Status
Level
Java

This content can't be printed from the browser. Use Export PDF with Pro for an offline copy.

Question 1
SL • Paper 1
Medium
SL • Paper 1
Medium

Brindle Repair stores details of technicians and repair jobs in a relational database. The tables Technician and Repair are shown below.

Technician table

technicianId (PK)technicianName
1Aisha Khan
2Ben Carter
3Chen Wei
4Dara Singh

Repair records at Brindle Repair.

repairId (PK)technicianId (FK)itemDescriptionquotedCost
113Laptop screen28
121Tablet battery65
133Phone charging port35
142Printer paper feed30
151Desktop fan42
162Router power supply18

In Technician, technicianId is the primary key. In Repair, repairId is the primary key and technicianId is a foreign key referencing Technician. The quotedCost field stores a whole number of currency units.

A

Outline why adding a new column to Repair is a data definition language (DDL) operation rather than a data manipulation language (DML) operation.

[2]
B

State two DML statements, other than SELECT and UPDATE, that staff could use to change the records in Repair.

[2]
C

Construct an SQL statement to change quotedCost to 45 for the repair with repairId 14. No other repair must be changed.

[3]
D

Construct an SQL query to display technicianName, itemDescription and quotedCost for repairs with a quotedCost greater than 30. Use a join between the two tables and display the results in descending order of quotedCost.

[5]
Question 2
SL • Paper 1
Medium
SL • Paper 1
Medium

Ternway Deliveries stores parcel details in the Parcel table shown below. Each parcel is assigned to a depot, and massKg stores its mass as a whole number of kilograms.

Parcel table; parcelId is the primary key and massKg is indexed.

parcelId (PK)depotNamedestinationDistrictmassKg (indexed)
P001East CentralRiverside2
P002North DepotHillview1
P003East HubRiverside4
P004West DepotLakeside6
P005East CentralOld Town5
P006South DepotHillview3
P007East HubLakeside2
P008Central DepotRiverside7

The primary key is parcelId. An additional index is maintained on massKg.

A

Outline why maintaining the index on massKg can add processing work when staff correct a parcel's mass.

[2]
B

State the SQL statement used to create a new table and the SQL statement used to remove a table's definition and all its records.

[2]
C

Construct an SQL query to display the destinationDistrict values for parcels with massKg between 2 and 5, including both endpoints. Each destination district must appear only once.

[3]
D

Construct an SQL query using GROUP BY and HAVING to display one row for each depotName that begins with 'East'. Display only depotName and arrange the results in ascending alphabetical order.

[5]
Question 3
HL • Paper 1
Medium
HL • Paper 1
Medium

Brindle Repairs maintains a relational database of technicians and repair jobs. The tables show an extract from the database; technicianID in REPAIR is a foreign key referencing TECHNICIAN, and hours records the time spent on a repair.

TECHNICIAN

TECHNICIAN table extract

technicianID (PK)technicianName
T101Aisha Khan
T102Daniel Wu
T103Elena García
T104Marcus Bell

REPAIR

REPAIR table extract

repairID (PK)technicianID (FK)hoursfeestatus
R001T101385Ready
R002T1022120In progress
R003T1014150Ready
R004T103695In progress
R005T1023110Ready
R006T1032175Ready
R007T104570In progress
A

Construct an SQL query to list repairID and fee for repairs whose status is 'Ready', in descending order of fee.

[3]
B

Construct an SQL query using both tables to list each technician's name and total hours spent on repairs. Include only technicians whose total hours are at least 6. Each technician must appear in a separate result row.

[5]
C

The manager frequently reads a summary of repair hours. A materialized view stores this summary and is refreshed overnight. Describe how this view affects the performance and currency of the information available to the manager.

[3]
D

Two staff members concurrently apply different increases to the fee for the same repair. Each transaction reads the existing fee, calculates a new fee and writes it back. Outline how isolation can prevent one increase from being lost.

[3]

A3.2 Database design

A3.4 Alternative databases and data warehouses