Share via


Relation Dialog: Relation Only, or with Foreign Key Constraint?

Using the Relation Dialog, you are asked to choose Relation Only, Foreign Key Constraint Only, or Both.  Which is the right choice? 

“Relation Only” makes available the tables related to the table that you are working with.  This means that if you are working with, for example, both a Customers table with CustomerID as primary key and an Orders table with CustomerID as foreign key, you can establish a relationship based on their common key (CustomerID) by inserting a relation.  Without the relation, the dataset is not able to keep track that CustomerID field in one table is related to the CustomerID field in another table.

Foreign key constraint enables enforcing constraints for what-is-called referential integrity, controlling changes to primary key data.  For example, if you tried to change a CustomerID value in the Customers table, the corresponding CustomerID value in the Orders table may no longer be valid.  A foreign key constraint is able to help prevent this situation.  With the foreign key constraint enabled, a failure will occur if changes are made to primary key values that have corresponding foreign key values.

A foreign key constraint only with no relation is implemented for efficiency, since it will contain fewer methods than one with relation.  However, related tables will not be accessible.

For further information, check out my sources:

Introduction to DataRelation Objects

Foreign Key Constraints

 

Yun Zhou

Comments