Home
Relationships - Do you turn on referential integrity in relationships?
  v1.0 Posted at 13/11/2019 11:12 AM by Tiago Araujo

Cascading referential integrity constraints allow you to define the actions SQL Server takes when a user attempts to delete or update a key to which existing foreign keys point. The REFERENCES clauses of the CREATE TABLE and ALTER TABLE statements support ON DELETE and ON UPDATE clauses:

  • [ ON DELETE { CASCADE | NO ACTION } ]
  • [ ON UPDATE { CASCADE | NO ACTION } ]

NO ACTION is the default if ON DELETE or ON UPDATE is not specified.​​

​Relationships should always have referential integrity turned on. If you turned it on after data has been added, you may have data in your database that violates your referential integrity rules.

ReferentialIntegrityCheck.jpg
Figure: Recommended referential integrity constraints

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: