0
0
SQLquery~10 mins

Soft delete pattern concept in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all active users who are not soft deleted.

SQL
SELECT * FROM users WHERE [1] = 0;
Drag options to blanks, or click blank then click option'
Ais_deleted
Bstatus
Cactive
Ddeleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name like 'deleted' or 'status' which may not exist.
Filtering with 'active' which might not be a column.
2fill in blank
medium

Complete the code to soft delete a user by setting the soft delete flag.

SQL
UPDATE users SET [1] = 1 WHERE user_id = 42;
Drag options to blanks, or click blank then click option'
Adeleted
Bactive
Cstatus
Dis_deleted
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to delete the row with DELETE statement instead of updating the flag.
Using a wrong column name.
3fill in blank
hard

Fix the error in the query to select only non-deleted products.

SQL
SELECT * FROM products WHERE [1] = 0;
Drag options to blanks, or click blank then click option'
Aactive
Bdeleted
Cis_deleted
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not exist like 'deleted' or 'status'.
Confusing the flag value (true/false vs 1/0).
4fill in blank
hard

Fill both blanks to select all active orders and sort them by creation date descending.

SQL
SELECT * FROM orders WHERE [1] = 0 ORDER BY [2] DESC;
Drag options to blanks, or click blank then click option'
Ais_deleted
Bdeleted
Ccreated_at
Dorder_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column for filtering or sorting.
Sorting ascending instead of descending.
5fill in blank
hard

Fill all three blanks to insert a new user with soft delete flag set to active (not deleted).

SQL
INSERT INTO users (username, email, [1]) VALUES ([2], [3], 0);
Drag options to blanks, or click blank then click option'
Ais_deleted
B'newuser'
C'newuser@example.com'
Ddeleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name for the flag.
Not quoting string values in the VALUES clause.