HomeCode HereDesign and safety quiz Design and safety quiz Admin 1 min read Updated November 16, 2026 Nine questions on keys, constraints, indexes, transactions and views. SQL Design and safety quiz 9 questions, instant feedback Question 1 of 9 What does a primary key guarantee? A Sorted rows B Uniqueness and non-null values for the key C A foreign key on every table D Automatic indexing of all columns A primary key identifies each row: no duplicates and no nulls. Most engines also index it. Question 2 of 9 What does a foreign key enforce? A That the referenced row exists B That the column is unique C That the table has an index D That values are positive A foreign key points at a row in another table and prevents values that reference nothing. Question 3 of 9 Which constraint prevents an empty value? A UNIQUE B NOT NULL C CHECK D DEFAULT NOT NULL rejects NULL. UNIQUE allows one NULL in most engines and prevents duplicates among real values. Question 4 of 9 What is an index for? A Enforcing uniqueness only B Making lookups and sorts faster at the cost of write speed and space C Storing a backup D Compressing the table An index is a sorted structure the engine can search without scanning the table. Every write must also update it. Question 5 of 9 Which columns benefit most from an index? A Columns in WHERE, JOIN and ORDER BY B Every column C Columns never queried D Only text columns Index what queries actually filter, join or sort on. Indexing everything slows writes for no gain. Question 6 of 9 What does a transaction guarantee? A Faster queries B That a group of statements commits completely or not at all C Automatic indexes D Read-only access A transaction is atomic: COMMIT saves all its statements, ROLLBACK discards them. Question 7 of 9 What is a view? A A saved copy of the data B A named query that behaves like a table C An index D A backup file A view stores the query, not the rows. It runs when selected, which keeps a complex report in one place. Question 8 of 9 What does ON DELETE CASCADE do? A Deletes the child rows when the parent row is deleted B Deletes the parent only C Prevents deletion D Moves rows to an archive Cascade removes dependent rows automatically. Without it, deleting a referenced parent fails unless you handle children first. Question 9 of 9 Which first step limits the damage of a DELETE? A Adding LIMIT 1 B Running the same WHERE as a SELECT and wrapping the delete in a transaction C Deleting at night D Disabling constraints Check the predicate returns exactly the rows you mean, then delete inside a transaction so a mistake can be rolled back. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes Summarising data quiz 9 questions Joins and changes quiz 9 questions SQL final quiz 10 questions All quizzes