3. Foreign key
Consider the relationship diagram shown below
Notice that the primary key in the City table is pointing to a similar field in the customer table, which happens to have the same name (it can be any name) - the field in the customer table is called the 'foreign key'.
A foreign key points to a record in another table whose primary key is the same value.
What is happening is that a copy of the primary key value in the City table is being stored in the customers table. For example, a typical record entry looks like this:
Mr & Mrs Jones live in the city of Hull and the foreign key in each record contains '2'. This then points to 'Hull' in the city table whose primary key is also '2'.
Note that is is quite common to have more than one record having the same foreign key. This simply reflects the fact that a one-to-many relationship exists between the two tables.
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: Using foreign keys
Copyright © www.teach-ict.com