What is the difference between a primary key and a foreign key in a relational database?

  • Data retrieval optimization
  • Data validation and integrity constraints
  • Table relationships and referential integrity
  • Uniqueness and indexing
A primary key uniquely identifies each record in a table and ensures that there are no duplicate values. It also automatically creates a unique index for fast data retrieval. On the other hand, a foreign key establishes a relationship between two tables, ensuring referential integrity and enforcing data constraints.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *