ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
9 marks · Query design
Spring classes for babies are ending soon. An email needs to be sent to all parents to offer them a place in the Summer classes. Design a query that could be used to generate a list of names and email addresses of parents with a child who attends a Spring class for babies. Field(s) Table(s) Search Criteria A new class is going to be added for Autumn which will be run by Adam. This is added by executing the following SQL statement. INSERT INTO Class (classID, leaderName, day, time, location, sessionBlock, classAge) VALUES ("B1-497", "Adam", "Mon", 15:30, "Grange","Autumn", "Babies"); Tim Roberts, who made booking TR238270, would like to book their child Lucas onto this new class. He has not yet paid for the class. Write an SQL statement that will add this booking to the Booking table, using the bookingID TR653726. Some data needs to be removed from this table. Class classID leaderName day time location sessionBlock classAge S1-141 Suzanne Mon 10:45 Grange Summer 1-2 Years S2-228 Claire Tue 11:50 Lothianburn Autumn 3-4 Years S2-871 Jo Mon 13:00 Gorebridge Spring 3-4 Years B1-121 David Thur 15:30 Biggar Winter Babies S1-333 Alexander Wed 13:00 Coldingham Summer 1-2 Years S2-519 Claire Fri 10:45 Lothianburn Autumn 3-4 Years B3-435 Jose Wed 09:30 Gorebridge Spring Babies … … … … … … … Claire is no longer able to run the 3-4 Years class on a Tuesday in the Autumn block. The SQL statement below is written to make the change. DELETE FROM Class WHERE leaderName = "Claire" AND classAge = "3-4 Years"; Give one reason why this SQL statement is not fit for purpose. The Gorebridge classes are no longer running. Write the SQL statement to remove all the Gorebridge classes. Bright Stars organise and run classes for children. Classes are organised into blocks, each running for 8 weeks. The table Class stores data about the classes available. The table Booking stores data about the children and their parents/guardians. Sample data from each table is shown below. Class classID leaderName day time location sessionBlock classAge S1-141 Suzanne Mon 10:45 Grange Summer 1-2 Years S2-228 Claire Tue 11:50 Lothianburn Autumn 3-4 Years S2-871 Jo Mon 13:00 Gorebridge Spring 3-4 Years B1-121 David Thur 15:30 Biggar Winter Babies S1-333 Alexander Wed 13:00 Coldingham Summer 1-2 Years S2-519 Claire Fri 10:45 Lothianburn Autumn 3-4 Years B3-435 Jose Wed 09:30 Gorebridge Spring Babies … … … … … … … Booking bookingID parentName email childName childDOB paid classID EF220731 Esme Faulds EFaulds22@mail.com Quinn 25/09/2022 No S1-333 TR238270 Tim Roberts TRoberts2@mail.com Lucas 05/02/2023 Yes B1-121 ZA200836 Zoe Archer ArcherLTD@mail.com Blake 11/01/2020 Yes S2-288 FY229853 Fen Yang FYang131@mail.com Freya 06/06/2022 No S1-333 … … … … … … …
One mark each for: • parentName, email with no other fields • Class, Booking • sessionBlock = Spring • classAge = Babies Field(s) • fields can be in any order Table(s) • table names can be in any order Search Criteria • conditions can be in any order Field(s) parentName, email Table(s) Class, Booking Search Criteria sessionBlock=Spring classAge = Babies One mark for the following SQL code: • INSERT INTO Booking • Correct VALUES Field names not required in INSERT INSERT INTO Booking VALUES("TR653726","Tim Roberts", "TRoberts2@mail.com" , "Luc as" , 05/02/2023, No, "B1- 497"); Notes: • Date may be - '2023/02/05' - #05/02/2023# - "05/02/2023" - '05/02/2023' • No may be 0, False or assumed to be text "No" All Claire’s ‘3-4 Years’ classes are removed. Accept that it deletes more than one record. Accept that it also deletes Friday’s class. Do not accept that it deletes all of Claire’s records. One mark for the following SQL code • DELETE FROM CLASS • WHERE location = "Gorebridge"