Primary and foreign key function in php | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Primary and foreign key function in php

I have a school project where we need to register student and then let them choose which sports they want to join. My problem is I don't get why do I need to use Primary key and foreign key. Can you tell me in as simple word or example. -17 years old kid

3rd Mar 2019, 11:56 AM
Mohd Zulhilmi (zul_3)
Mohd Zulhilmi (zul_3) - avatar
2 Answers
+ 3
//The primary key consists of one or more columns whose data contained within is used to uniquely identify each row in the table. You can think of the primary key as an address. If the rows in a table were mailboxes, then the primary key would be the listing of street addresses. //A foreign key is a set of one or more columns in a table that refers to the primary key in another table.  There isn’t any special code, configurations, or table definitions you need to place to officially “designate” a foreign key. //for details description here is source https://www.dotnettricks.com/learn/sqlserver/difference-between-primary-key-and-foreign-key
3rd Mar 2019, 12:02 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
Thank you sir for the meaningful reply now I get what it means after searching for a long time.
25th Mar 2019, 11:53 AM
Mohd Zulhilmi (zul_3)
Mohd Zulhilmi (zul_3) - avatar