Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Databases
Databasesmedium

Constraints vs triggers — what’s the difference and what do you prefer for integrity?

Tags
#constraints#triggers#integrity
Back to categoryPractice quiz

Answer

Constraints (PK, FK, UNIQUE, CHECK) are declarative rules enforced by the DB engine. Triggers are custom code that runs on events. Prefer constraints for data integrity when possible because they’re simpler, predictable, and optimized.

Related questions

Databases
Foreign keys: why use them and what’s a trade‑off?
#database#foreign-key#integrity
Databases
Primary key vs unique constraint: what’s the difference?
#database#constraints#primary-key
Databases
What is a foreign key and what does it enforce?
#foreign-key#constraints#integrity
Databases
Primary key vs unique constraint vs index — what’s the difference?
#primary-key#unique#index