Foreign Key in DBMS
Q.1: What is main difference between foreign key and primary key?
Answer:
A primary key is used to ensure data in the specific column is unique. A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables.
Q.2: Is it necessary that the referenced column should have a primary key ?
Answer:
It is mandatory that the other column must have a primary key as it references the data which is related in different tables and creates a relational structure.
Q.3: Can a foreign key reference a column in own table?
Answer:
Yes, it is possible for a foreign key to reference a column in its own table and it is called as Self-Reference.
Foreign Key in DBMS
In DBMS, there are different types of keys available that are used for various purposes. Foreign Key is a column that refers to the primary key/unique key of another table. So it demonstrates the relationship between tables and acts as the cross reference among them.
Contact Us