1 Answers
Key Differences between Primary Key and Foreign Key in a Database
Primary Key:
- Uniquely identifies each record in a table.
- Must contain unique values and cannot have NULL values.
- Usually consists of a single column or a combination of columns.
- Enforces entity integrity.
Foreign Key:
- Establishes a link between two tables.
- References the primary key of another table to maintain referential integrity.
- Can have duplicate values and can also contain NULL values.
- Helps in establishing relationships between tables.
In summary, the primary key uniquely identifies records within a table, whereas the foreign key establishes relationships between tables by referencing the primary key of another table.
Please login or Register to submit your answer