Computer Science, asked by TbiaSupreme, 1 year ago

Explain the concept of foreign key giving suitable example.

Answers

Answered by MOSFET01
4
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.

SQL > Constraint > Foreign Key. A foreign keyis a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign keyis to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.
Answered by gratefuljarette
2

Foreign key:

A foreign key is a column of a table that refers to the values of the primary key or candidate key of another table.  

Example:

  • If we have a student table which consists of student name, student Id, date of birth, date of admission, class and we have another table know as course table which consists of course id, course name, and date of registration.
  • Suppose we have a course enrollment table which consists of columns of both course table and student tables like course id and student id. In this above example: student id will be the foreign key for this course enrollment table since it acts as a primary key for the student table.

Learn more about foreign key

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

https://brainly.in/question/10702307

WHAT IS THE RELATIONSHIP BETWEEN PRIMARY KEY AND FOREIGN KEY?

https://brainly.in/question/8438365

Similar questions