Testing that stored data changed correctly
Run a SELECT before and after an INSERT, UPDATE or DELETE, then compare both results with the expected data and check that no other rows changed.
Understanding Testing that stored data changed correctly in QCE Digital Solutions Unit 2
What it does: This 'after' SELECT shows the stored points value, which you compare with the expected result of the UPDATE. Rows other than studentId 1 should be identical to the before results. Any difference is an unintended change. The before result is your baseline. Without it you cannot tell what the DELETE actually removed. Checking the whole table lets you confirm the Red rows are gone and every other row is still there. A correct target row is not enough. The test must also show that no other rows changed. Working out the expected data first means you are testing against a requirement, not just accepting whatever the table shows.
Common mistakes: The WHERE clause must match only the student being tested (studentId = 1). Using yearLevel = 7 changes every Year 7 student, so the before and after SELECTs would show unintended changes to other rows. The 'before' query must run on the same table that the DELETE changes. Counting results tells you nothing about orders, so it should be SELECT COUNT(*) FROM orders;.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 337–409) and word search (Modules 234–409).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
SELECT * FROM students;Fill in the Blanks
Spot the Error
Student with a class code? Join your class →