Computer Science, asked by Anonymous, 10 months ago

Explain the salient features of foreign key with help of example?

Answers

Answered by EHSASS
2

★彡 Here Is Your Answer 彡★

A foreign key is a mechanism in a relational database that allows for the association of those tables, or for the

tables to have a relationship with one another. There are unique characteristics that a foreign key must have.

A foreign key guarantees that rows in one table correspond to rows in some other table, thereby establishing

database-wide relationships, or references. The table containing the foreign key is the "child," and the other

table is the "parent."

Foreign Key Example:-

Faculty (Fac_Id, department, rank, name)

Class (Class_No, Fac_Id, Schedule, room)

Fac_Id is the foreign key in Class Relation as it is primary key in other Relation Faculty.

According to definition An attribute of a table B that is primary key in another table A is called as foreign key.

Ehsass 彡★

Answered by devanayan2005
1

A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.

The majority of tables in a relational database system adhere to the foreign key concept. In complex databases and data warehouses, data in a domain must be added across multiple tables, thus maintaining a relationship between them. The concept of referential integrity is derived from foreign key theory.

Foreign keys and their implementation are more complex than primary keys.

Example.....

EmployeeId INTEGER NOT NULL UNIQUE;

This will enforce the "EmployeeId" value to be unique, no duplicated values will be allowed. Note that, this applies on the values of the column "EmployeeId" only.

HOPE THIS HELPS YOU!!!

Similar questions