Главная страница
Содержание
 
 

FOREIGN KEY

 

A foreign key is a set of attributes of some relation variable (relvar) R2 whose values are required to match values of some candidate key of some relvar R1. For example, consider the set of attributes {S} of relvar SP. It should be clear that a given value for {S} can be allowed to appear in relvar SP only if that same value also appears as a value of the sole candidate key, {S} for relvar S. These examples serve to motivate following definition:

Let R2 be a relvar. Then a foreign key in R2 is a set of attributes of R2, say F, so that:

·         There exists a relvar R1 (R1 and R2 not necessarily distinct) with a candidate key CK.

·         It is possible to rename some subset of the attributes of FK, such that FK becomes FK (say) and FK and CK are of the same (tuple) type.

·         For all time, each value of FK in the current value of R2 yields a value for FK that is identical to the value of CK in some tuple in the current value of R1.

Synopsys:

FOREIGN KEY ( column [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] [ ON DELETE action ] [ ON UPDATE action ]

 

<< К содержанию >>