Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Insertion, update and deletion anomalies worksheet is part of the WA Computer Science ATAR Year 11 — Data Management journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1INSERT INTO Orders VALUES (9, 'Ava', 'Year 7', 'Red'); | AThis update leaves inconsistent copies. The teacher's name is stored in many rows, so updating one row creates an update anomaly. The fix is to store the teacher once in a separate table. | |
| 2UPDATE Orders SET house = 'Blue' WHERE orderId = 4; | BINSERT INTO Orders (productId, name, price) VALUES (11, 'Ruler', 2); | |
| 3Delete anomaly: removing the only row that mentions a product also erases the product's details. | CIn a single big table, repeating the student's details in every new row is wasteful and risks mistakes. This is where an insert anomaly can arise. | |
| 4Insert anomaly: a new product cannot be stored until someone orders it, because the table needs order details too. | DDELETE FROM Orders WHERE orderId = 7; | |
| 5Fix a teacher's name in one row only, so Maths shows 'Ms Lee' in one row and 'Ms Li' in another. | EChanging the house in only one row leaves other rows for the same student unchanged. This causes an update anomaly with inconsistent copies. | |
| 6DELETE FROM Orders WHERE studentId = 3; -- just to remove their old orders | FDeleting these rows also removes the only copy of the student's details, causing a delete anomaly. The fix is to keep student details in their own Students table. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
data anomaly — A problem caused by redundant data in one table: adding, changing or deleting a record leads to missing data, inconsistent copies or accidental loss of other facts.INSERT INTO Enrolment (StudentID, CourseCode)
VALUES (NULL, 'C10');UPDATE Enrolment
SET CourseName = 'Databases 2'
WHERE CourseCode = 'C10';DELETE FROM Enrolment
WHERE StudentID = 12;SELECT DISTINCT CourseName
FROM Enrolment
WHERE CourseCode = 'C10';UPDATE Course
SET CourseName = 'Databases 2'
WHERE CourseCode = 'C10';