In the relational databases, a foreign key is a field or a column that is used to establish a link between two tables. In simple words you can say that, a foreign key in one table used to point primary key in another table.
In the Referential integrity constraints, if a foreign key in Table-1 refers to the Primary Key of Table-2, then every value of the Foreign Key in Table-1 must be null or be available in Table-2.
- teach (s_code, c_code, f_code)
s_code, c_code and f_code are the Foreign Keys in the teach table, but –
s_code is the Primary Key of the student table.
c_code is the Primary Key of the course table.
f_code is the Primary Key of the faculty table. - test_schedule (exam_code, week_number, full_marks, c_code)
c_code is the Foreign Key in the test_schedule table, but –
c_code is the Primary Key of the course table. - test_result (s_code, exam_code, grade)
s_code and exam_code are the Foreign Keys in the test_result table, but –
s_code is the Primary Key of the student table.
exam_code is the Primary Key of the test_schedule table. - classes (class_code, duration, class_type, date_and_time, c_code, f_code)
c_code and f_code are the Foreign Keys in the classes table, but –
c_code is the Primary Key of the course table.
f_code is the Primary Key of the faculty table.