Primary Key vs Foreign Key in Relational Database
In a relational database, the primary key and foreign key are both important concepts that help establish relationships between tables. Here is the difference between them:
Primary Key:
A primary key is a unique identifier for each record in a table. It ensures that each row in a table is uniquely identified and cannot have duplicate values. The primary key is used to uniquely identify records and is often a combination of one or more columns in a table.
Foreign Key:
A foreign key is a field in a table that links to the primary key of another table. It establishes a relationship between two tables based on the values in the linked columns. The foreign key ensures referential integrity and helps maintain the relationships between tables in the database.
Overall, the primary key is used to uniquely identify records within a table, while the foreign key is used to establish relationships between tables in a relational database.
Please login or Register to submit your answer