it depends on how the relationship is enforced - but in essence
table a foreign key relates to table b primary key
table a field that relates cannot have any value that does not exist in table b primary key
it's a constraint to prevent you entering data that would be incorrect.
they can also be used to cascade changes - for example cascading deletes mean that if you delete the row in table b, all the rows un table a that have the foreign key value are also deleted.