SQL Server Interview Topic 33: Constraints Deep Dive
This topic checks whether you understand how SQL Server protects data before wrong values enter the table.
You should be able to explain each common constraint and give one real example from a School Management System.
Q200. What is a NOT NULL constraint?
Quick interview answer:
NOT NULL means a column must have a value. For example, student name should not be empty because every student record needs a name. It protects required data.
Study in detail: Constraints - This lesson explains database rules.
Q201. What is a UNIQUE constraint?
Quick interview answer:
A UNIQUE constraint stops duplicate values in a column or group of columns. For example, admission number or email can be unique so two students do not share the same value.
Study in detail: Constraints - This article explains unique rules with examples.
Q202. What is a CHECK constraint?
Quick interview answer:
A CHECK constraint validates values using a condition. For example, marks can be checked so they stay between 0 and 100. It prevents invalid values from entering the table.
Study in detail: Constraints - This lesson explains validation rules.
Q203. What is a DEFAULT constraint?
Quick interview answer:
A DEFAULT constraint gives a column a value when no value is supplied. For example, IsActive can default to 1 when a new student is inserted.
Study in detail: Constraints - This article explains default values.
Q204. Constraint vs application validation: which is better?
Quick interview answer:
Both are important. Application validation gives a better user experience, while database constraints protect the data even if another tool, script, or API tries to insert wrong values.
Study in detail: Data Quality and Security - This topic explains why database rules still matter.
Constraint answers sound stronger when you explain what bad data the constraint prevents.