5 questions to test your understanding
A web application validates that a user's age is ≥ 18 in its Python code before inserting into the database, but no CHECK constraint exists on the column. A data analyst runs a direct SQL INSERT through a terminal session. What happens?
Which statement best describes the difference between UNIQUE and PRIMARY KEY constraints?
A FOREIGN KEY constraint prevents inserting a row whose foreign key value has no matching primary key in the referenced table.
A CHECK constraint defined in the database schema is redundant if the application layer already validates the same rule, because the data will be validated before it reaches the database.
Why is it better to enforce business rules like 'age must be positive' and 'email must be unique' as database constraints rather than relying solely on application code?