Easy Database Systems Database Design
What is the difference between a primary key and a foreign key?
Answer
A primary key uniquely identifies each row in a table - it must be unique, not null, and there can be only one per table. A foreign key is a column that references the primary key of another table, establishing a relationship between tables. Foreign keys enforce referential integrity - values must exist in the referenced table or be null (if allowed). Example: order.customer_id references customer.id.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Software Engineer Backend Developer Database Developer