Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 1 of 2.
For each term, write a definition and an example from HOUSE_RENTALS.
Field: a column (attribute) in a table. [1]
Example: CustomerID in the table CUSTOMER. [1]
Entity: anything that data can be stored about. [1]
Example: a customer or a house. [1]
Foreign key: a field in one table that links to the primary key of another table. [1]
Example: CustomerID (or HouseID) in the table RENTAL. [1]
Tick In 3NF.
Every field in every table depends fully on the primary key and on no other field. [1]
Example: all fields in CUSTOMER depend only on CustomerID. [1]
CREATE TABLE RENTAL (
RentalID INTEGER NOT NULL,
CustomerID INTEGER NOT NULL,
HouseID VARCHAR(5) NOT NULL,
MonthlyCost REAL NOT NULL,
DepositPaid BOOLEAN NOT NULL,
PRIMARY KEY (RentalID)
);CREATE TABLE [1]
VARCHAR for HouseID [1]
REAL (or CURRENCY) for MonthlyCost [1]
PRIMARY KEY [1]
The names are in CUSTOMER and the deposit is in RENTAL, so join the two tables.
SELECT FirstName, LastName FROM CUSTOMER, RENTAL WHERE DepositPaid = No AND RENTAL.CustomerID = CUSTOMER.CustomerID;
SELECT FirstName and LastName [1]
FROM both tables [1]
WHERE DepositPaid = No [1]
Tables joined (with AND, or with INNER JOIN) [1]
▶ Whole paper
Video solution of the whole paper · by O/Alevel CS by Wasiq. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.