what is the difference between foreign key and primary key?? what is the Syntex to define these two?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the difference between foreign key and primary key?? what is the Syntex to define these two??

5th Sep 2016, 4:09 PM
Dheeraj Kumar Adya
Dheeraj Kumar Adya - avatar
3 Answers
+ 4
A Foreign Key is basicly the Primary Key from other table that you added to this one so you could correlate them. Example: say you are Ebay, you probably have a table named "sellers" and another one named "items", the PK (Primary Key) of your seller table (where id 0 is a seller, id 1 is another seller, so on and so forth) could he added to the items table as a FK (Foreign Key), assembling each item to a seller ID, so if this column is = 1, you know that you just have to go to the sellers table and see whom of your seller have this Id to correlate the item with the person selling it. Hope it helped!
6th Sep 2016, 12:50 AM
Renan Ben Moshe
Renan Ben Moshe - avatar
+ 3
best answer is:1) A foreign key is a column or combination of columns that is used to establish a link between the data in two tables. 2) A primary key is a relational key in a database that is unique for each word e.g ID number, passport number but one thing you should know that for making foreign relations you must have primary key for reference. "hope i answered you"
5th Sep 2016, 5:03 PM
muhammad ahmed
muhammad ahmed - avatar
- 1
j'adore SoloLearn
8th Sep 2016, 7:03 PM
Hissene Abdelwahid
Hissene Abdelwahid - avatar