Databases and SQL: Question 6
Syllabus 9.2
Trailhead Bike Rentals stores every bike hire it makes in a single database table called BIKE_RENTAL, shown below.
| RentalID | CustomerName | BikeType | DurationHours | HelmetRequested |
|---|---|---|---|---|
| R201 | Priya Nair | Mountain | 2 | True |
| R202 | Owen Clarke | Road | 3 | False |
| R203 | Priya Nair | Hybrid | 1 | True |
| R204 | Maya Lindqvist | Mountain | 2 | False |
Which field should be chosen as the primary key for the BIKE_RENTAL table?
Show worked solution Hide worked solution
Worked solution
Step 1: Recall what a primary key must do
A primary key must hold a value that is different for every record in the table, so that any single record can always be identified precisely.
Step 2: Check each candidate field for repeated values
- CustomerName: “Priya Nair” appears twice (R201 and R203), so it repeats.
- BikeType: “Mountain” appears twice (R201 and R204), so it repeats.
- DurationHours: the value 2 appears twice (R201 and R204), so it repeats.
- RentalID: R201, R202, R203 and R204 are all different from one another.
Step 3: Confirm the match
Only RentalID gives a genuinely different value for every record shown, and there is no reason to expect two rentals would ever share the same RentalID, so it is the only field able to serve reliably as the primary key.
Final answer
The primary key should be RentalID, option D.