Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Referential integrity
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Declarative referential integrity== '''Declarative referential integrity''' (DRI) is one of the techniques in the [[SQL]] database programming language to ensure data integrity. ===Meaning in SQL=== {{main|Foreign key}} A table (called the referencing table) can refer to a column (or a group of columns) in another table (the referenced table) by using a [[foreign key]]. The referenced column(s) in the referenced table must be under a unique constraint, such as a [[primary key]]. Also, self-references are possible (not fully implemented in MS SQL Server though<ref>{{cite web |author=Microsoft Support |date=2007-02-11 |title=Error message 1785 occurs when you create a FOREIGN KEY constraint that may cause multiple cascade paths |publisher=microsoft.com |url=http://support.microsoft.com/kb/321843/en-us |access-date=2009-01-24}}</ref>). On [[Insert (SQL)|inserting]] a new [[Row (database)|row]] into the referencing table, the [[relational database management system]] (RDBMS) checks if the entered key value exists in the referenced table. If not, no insert is possible. It is also possible to specify DRI actions on [[Update (SQL)|UPDATE]] and [[Delete (SQL)|DELETE]], such as CASCADE (forwards a change/delete in the referenced table to the referencing tables), NO ACTION (if the specific row is referenced, changing the key is not allowed) or SET NULL / SET DEFAULT (a changed/deleted key in the referenced table results in setting the referencing values to NULL or to the DEFAULT value if one is specified).<ref> ANSI/ISO/IEC 9075-1:2003, Information technology—Database languages—SQL * Part 1: Framework (SQL/Framework) * Part 2: Foundation (SQL/Foundation) </ref> ===Product-specific meaning=== In [[Microsoft SQL Server]] the term DRI also applies to the assigning of permissions to users on a [[database object]]. Giving DRI permission to a database user allows them to add foreign key constraints on a table.<ref>{{cite web |last=Chigrik |first=Alexander |date=2003-08-13 |title=Managing Users Permissions on SQL Server |publisher=Database Journal |url=http://www.databasejournal.com/features/mssql/article.php/2246271 |access-date=2006-12-17}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)