SQL Fundamentals

Constraints and Data Integrity

Choose NOT NULL, UNIQUE, CHECK, primary-key, and foreign-key constraints from concrete integrity rules and verify both accepted and rejected writes.

Intermediate14 min read
SQL Fundamentals lessonRelational data foundationsPractice

UNTIMED COACHING

Practice before the pressure

Use feedback to correct the model, not merely memorize an option position.

GUIDED PRACTICE

Practice the lesson questions

Answer normal lesson questions without a timer. Every answer includes an explanation, and incorrect answers can be tried again before continuing.

CONCEPT MODELS

See the lesson as a system

Use these visual guides to connect the key ideas before answering the questions.

Connect the roles in Constraints and Data IntegrityKeep candidate row, required value, unique identity, and parent relationship as separate roles.
Connect the roles in Constraints and Data IntegrityA topic-specific model connects four distinct roles used to reason about constraints and data integrity.
Input rowData carries one proposed order record
Required decisionDecision requires order time and quantity
Index recordTable record blocks duplicate order numbers
Table connectionConnection validates the customer key
Verify Constraint evidenceConnect constraint evidence with its topic-specific inspection, expected outcome, and protected database boundary.
Verify Constraint evidenceA verification model for constraints and data integrity connects the final data decision to its check, result, and protected boundary.
Output evidenceEvidence covers accepted and rejected writes
Starting checkReview output evidence
Expected resultEach invalid write fails for the database rule
Safety boundaryProtect input row scope