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

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » Tables, views, and indexes


Foreign keys

A foreign key consists of a column or set of columns. It represents a reference to a row in the primary table with the matching key value. Foreign keys can only be used with base tables; they cannot be used with temporary tables, global temporary tables, views, or materialized views. A foreign key is sometimes called a referential constraint as the base table containing the foreign key is called the referencing table and the table containing the primary key is called the referenced table.

If the foreign key is nullable, then the relationship is optional as the foreign row may exist without a corresponding match of a primary key value in the referenced table since neither primary keys nor UNIQUE constraint columns can be NULL. If foreign key columns are declared NOT NULL, then the relationship is mandatory and each row in the referencing table must contain a foreign key value that exists as a primary key in the referenced table.

 Foreign keys and orphaned rows
 Composite foreign keys
 Foreign key indexes and sorting order
 Example 1
 Example 2
 See also

Creating a foreign key (Sybase Central)
Creating a foreign key (SQL)