Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere 10 - Introduction » Overview of Data Management Technologies » Relational database concepts » Relations between tables

Primary keys Next Page

Foreign keys

The information in one table is related to that in other tables by foreign keys.


The SQL Anywhere sample database has one table holding employee information and one table holding department information. The Departments table has the following columns:

To find the name of a particular employee's department, there is no need to put the name of the employee's department into the Employees table. Instead, the Employees table contains a column holding a number that matches one of the DepartmentID values in the Departments table.

The DepartmentID column in the Employees table is called a foreign key to the Departments table. A foreign key references a particular row in the table containing the corresponding primary key.

In this example, the Employees table (which contains the foreign key in the relationship) is called the foreign table or referencing table. The Departments table (which contains the referenced primary key) is called the primary table or the referenced table.