Question bank › GCSE › GCSE Computer Science › Relational databases and SQL

SQL: SELECT, INSERT, UPDATE, DELETE

10 questions38 marksabout 45 min

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 4–53 marks

A gym stores data in a relational database with two tables, Members and Bookings.

Members

MemberIDFirstNameSurnameTownJoinYear
101AmiraKhanLeeds2021
102BenClarkeYork2023
103ChloeEvansLeeds2022
104DanielOkaforHull2020
105EllaMorganBradford2024
106FemiAdeyemiLeeds2023

Bookings

BookingIDMemberIDClassNameDay
B01101YogaMon
B02103SpinTue
B03102YogaWed
B04106PilatesMon
B05103YogaThu
B06105SpinFri

Write an SQL query to display the first name and surname of every member who lives in Leeds, in alphabetical order of surname. [3]

2Grade 6–73 marks

A gym stores data in a relational database with two tables, Members and Bookings.

Members

MemberIDFirstNameSurnameTownJoinYear
101AmiraKhanLeeds2021
102BenClarkeYork2023
103ChloeEvansLeeds2022
104DanielOkaforHull2020
105EllaMorganBradford2024
106FemiAdeyemiLeeds2023

Bookings

BookingIDMemberIDClassNameDay
B01101YogaMon
B02103SpinTue
B03102YogaWed
B04106PilatesMon
B05103YogaThu
B06105SpinFri

Give the results of the following SQL query. [3]

SELECT MemberID, Surname
FROM Members
WHERE JoinYear >= 2022 AND Town <> 'York'
ORDER BY Surname DESC
3Grade 6–74 marks

A gym stores data in a relational database with two tables, Members and Bookings.

Members

MemberIDFirstNameSurnameTownJoinYear
101AmiraKhanLeeds2021
102BenClarkeYork2023
103ChloeEvansLeeds2022
104DanielOkaforHull2020
105EllaMorganBradford2024
106FemiAdeyemiLeeds2023

Bookings

BookingIDMemberIDClassNameDay
B01101YogaMon
B02103SpinTue
B03102YogaWed
B04106PilatesMon
B05103YogaThu
B06105SpinFri

(a) Write an SQL statement to add a new booking: booking B07 for member 104 to attend Pilates on Sat. [2]

(b) Member 104 has moved to Wakefield. Write an SQL statement to update their record. [2]

Stuck on SQL: SELECT, INSERT, UPDATE, DELETE?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4Grade 8–94 marks

A gym stores data in a relational database with two tables, Members and Bookings.

Members

MemberIDFirstNameSurnameTownJoinYear
101AmiraKhanLeeds2021
102BenClarkeYork2023
103ChloeEvansLeeds2022
104DanielOkaforHull2020
105EllaMorganBradford2024
106FemiAdeyemiLeeds2023

Bookings

BookingIDMemberIDClassNameDay
B01101YogaMon
B02103SpinTue
B03102YogaWed
B04106PilatesMon
B05103YogaThu
B06105SpinFri

Write an SQL query to display the first name and surname of every member who has booked a Yoga class. [4]

5Grade 6–74 marks

A gym stores data in a relational database with two tables, Members and Bookings.

Members

MemberIDFirstNameSurnameTownJoinYear
101AmiraKhanLeeds2021
102BenClarkeYork2023
103ChloeEvansLeeds2022
104DanielOkaforHull2020
105EllaMorganBradford2024
106FemiAdeyemiLeeds2023

Bookings

BookingIDMemberIDClassNameDay
B01101YogaMon
B02103SpinTue
B03102YogaWed
B04106PilatesMon
B05103YogaThu
B06105SpinFri

(a) Write an SQL statement to delete member 102 from the Members table. [2]

(b) Explain the problem this would cause in the Bookings table. [2]

6Grade 1–33 marks

A cinema stores data in a relational database with two tables, Films and Screenings. Runtime is in minutes and Seats is the number of seats available for that screening.

Films

FilmIDTitleCertificateRuntime
F1Night Harbour15118
F2Paper KitesPG95
F3Iron Meadow12A132
F4Small Hours15101
F5Glass OrchardU88

The SQL query below should display the title of every film with certificate 15, with the longest film shown first.

Complete the query by filling in the three gaps. [3]

SELECT ________
FROM Films
WHERE ________
ORDER BY Runtime ________
7Grade 4–53 marks

A cinema stores data in a relational database with two tables, Films and Screenings. Runtime is in minutes and Seats is the number of seats available for that screening.

Films

FilmIDTitleCertificateRuntime
F1Night Harbour15118
F2Paper KitesPG95
F3Iron Meadow12A132
F4Small Hours15101
F5Glass OrchardU88

Give the results of the following SQL query. [3]

SELECT Title, Runtime
FROM Films
WHERE Runtime < 100 OR Certificate = '12A'
ORDER BY Runtime ASC
8Grade 4–54 marks

A cinema stores data in a relational database with two tables, Films and Screenings. Runtime is in minutes and Seats is the number of seats available for that screening.

Screenings

ScreeningIDFilmIDScreenDaySeats
S01F21Fri110
S02F12Fri64
S03F31Sat150
S04F23Sat42
S05F52Sun97
S06F31Sun150
S07F43Sat58

(a) Screening S04 is being moved to Screen 2, where 120 seats will be available. Write an SQL statement to make this change in the Screenings table. [2]

(b) A student writes the statement below instead.

UPDATE Screenings SET Seats = 120

Explain the effect this statement would have on the database. [2]

9Grade 6–75 marks

A cinema stores data in a relational database with two tables, Films and Screenings. Runtime is in minutes and Seats is the number of seats available for that screening.

Screenings

ScreeningIDFilmIDScreenDaySeats
S01F21Fri110
S02F12Fri64
S03F31Sat150
S04F23Sat42
S05F52Sun97
S06F31Sun150
S07F43Sat58

(a) Film F3 has been withdrawn. Write an SQL statement to remove every screening of film F3 from the Screenings table. [2]

(b) State how many records the Screenings table will contain after the statement in part (a) has been run. [1]

(c) A new screening is then added: screening S08 of film F5 in Screen 3 on Fri with 75 seats. Write an SQL statement to add this record. [2]

10Grade 8–95 marks

A cinema stores data in a relational database with two tables, Films and Screenings. Runtime is in minutes and Seats is the number of seats available for that screening.

Films

FilmIDTitleCertificateRuntime
F1Night Harbour15118
F2Paper KitesPG95
F3Iron Meadow12A132
F4Small Hours15101
F5Glass OrchardU88

Screenings

ScreeningIDFilmIDScreenDaySeats
S01F21Fri110
S02F12Fri64
S03F31Sat150
S04F23Sat42
S05F52Sun97
S06F31Sun150
S07F43Sat58

Write an SQL query to display the title of each film and the day of its screening, for every screening on Sat that has more than 50 seats available. The results should be in alphabetical order of title. [5]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session