Ok. So I know what a primary key in DB is. If you have a table in a database, a primary key is a single value that is unique to each row in your table. For example:
id | name | whatever
-------------------------
1 Alice ....
2 Bob ....
45 Eve ....
988 .... ....
So I need a good, simple example to explain what exactly a foreign key is. Because I just don't get it :)
Edit: OK it's pretty easy, I guess I was over-complicating the problem.
So one final question, the only restriction on foreign keys is that it they are a valid primary key value in the table I am referring to?
The foreign key points from the person table (first) to a row in the country table (second)
Let's say you have another field, which is the home city:
Now, it does not make sense to repeat the same cities in many rows. This could lead you to typos, excessive space usage, difficulties to bring up results among other problems. So you use a foreign key:
home city table:
Hope it makes things clearer for you. :-)
Update: about your final question: Yes. :-)