docs.intersystems.com
Home  /  Application Development: Core Topics  /  Class Definition Reference  /  Class Definitions  /  Foreign Key Definitions


Class Definition Reference
Foreign Key Definitions
[Back]  [Next] 
InterSystems: The power behind what matters   
Search:  


Describes the structure of a foreign key definition.
Introduction
A foreign key defines a referential integrity constraint. When a table containing a foreign key constraint is modified, the foreign key constraints are checked.
You can add foreign key definitions to persistent classes. They are not meaningful in other kinds of classes.
Note that you can also enforce reference integrity by defining relationship properties that connect the classes.
Details
A foreign key definition has the following structure:
/// description 
ForeignKey name(key_props) References referenced_class(ref_props) [ keyword_list ]; 
Where:
Example
ForeignKey EmpKey(EmpId) References MyApp.Employee(EmpID) [ OnDelete = cascade ];
See Also