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
Databaseseasy

Primary key vs unique constraint vs index — what’s the difference?

Tags
#primary-key#unique#index#constraints
Back to categoryPractice quiz

Answer

A primary key uniquely identifies a row (and can be referenced by FKs). A unique constraint also enforces uniqueness, but isn’t “the” row identity. An index is a data structure that speeds up reads; it may be unique or not.

Related questions

Databases
Primary key vs unique constraint: what’s the difference?
#database#constraints#primary-key
Databases
Constraints vs triggers — what’s the difference and what do you prefer for integrity?
#constraints#triggers#integrity
Databases
What is a composite (multi-column) index and when does it help?
#index#composite-index#performance
Databases
What is a covering index?
#index#covering-index#performance
Databases
What is a foreign key and what does it enforce?
#foreign-key#constraints#integrity
Databases
What does an index do and what is the main trade-off?
#index#performance#tradeoffs