SQL - Table ConstraintsWhy might a UNIQUE constraint be preferred over a PRIMARY KEY constraint on a column?AUNIQUE constraints cannot be dropped, PRIMARY KEY canBUNIQUE automatically creates an index, PRIMARY KEY does notCPRIMARY KEY allows duplicates, UNIQUE does notDUNIQUE allows multiple NULLs, PRIMARY KEY does notCheck Answer
Step-by-Step SolutionSolution:Step 1: Compare UNIQUE and PRIMARY KEY constraintsPRIMARY KEY requires unique and NOT NULL values; UNIQUE enforces uniqueness on non-NULL values and permits multiple NULLs.Step 2: Identify key differenceUNIQUE allows multiple NULLs, which PRIMARY KEY does not.Final Answer:UNIQUE allows multiple NULLs, PRIMARY KEY does not -> Option DQuick Check:UNIQUE permits NULLs, PRIMARY KEY forbids them [OK]Quick Trick: UNIQUE allows NULLs; PRIMARY KEY requires NOT NULL [OK]Common Mistakes:MISTAKESThinking PRIMARY KEY allows NULLsBelieving UNIQUE does not create indexesConfusing drop behavior of constraints
Master "Table Constraints" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Advanced Joins - FULL OUTER JOIN behavior - Quiz 9hard Advanced Joins - Non-equi joins - Quiz 2easy Advanced Joins - CROSS JOIN cartesian product - Quiz 10hard Advanced Joins - Self join for hierarchical data - Quiz 10easy Aggregate Functions - COUNT function behavior - Quiz 9hard GROUP BY and HAVING - WHERE vs HAVING mental model - Quiz 7medium INNER JOIN - Why joins are needed - Quiz 12easy INNER JOIN - INNER JOIN syntax - Quiz 1easy LEFT and RIGHT JOIN - LEFT JOIN with NULL result rows - Quiz 14medium Table Constraints - NOT NULL constraint - Quiz 2easy