+ 3
What is foreign key?
3 Answers
+ 1
In SQL it is a key in a table that points to a primary key in another table. A way to connect tables. You can read more about it here >> http://www.w3schools.com/sql/sql_foreignkey.asp
it can explain it better than I as well đ
+ 1
A foreign key is a primary key from one table in another table.
Database containing two tables, Student and Grade. Student contains details about a student (name, age, etc) and Grade contains grade information (when applied, what level, what area).
The student table has a primary key of "STUDENT_ID", so a single STUDENT_ID can identify a single student.
The Grade table has a primary key of "GRADE_ID" so a single grade ID can identify an instance of a grade
To link them together (So we know which student gets which grade), we need a foreign key in the Grade table. Something to tell us which student got that grade. We can add "STUDENT_ID" into the grade table, and then this means we can join the Student table to the Grade table, on the STUDENT_ID.
Now, we can say, which student got which grade.
Does that help?
0
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.