<s>
Referential	B-General_Concept
integrity	I-General_Concept
is	O
a	O
property	O
of	O
data	O
stating	O
that	O
all	O
its	O
references	O
are	O
valid	O
.	O
</s>
<s>
In	O
the	O
context	O
of	O
relational	B-Application
databases	I-Application
,	O
it	O
requires	O
that	O
if	O
a	O
value	O
of	O
one	O
attribute	O
(	O
column	O
)	O
of	O
a	O
relation	B-Language
(	O
table	B-Application
)	O
references	O
a	O
value	O
of	O
another	O
attribute	O
(	O
either	O
in	O
the	O
same	O
or	O
a	O
different	O
relation	B-Language
)	O
,	O
then	O
the	O
referenced	O
value	O
must	O
exist	O
.	O
</s>
<s>
For	O
referential	B-General_Concept
integrity	I-General_Concept
to	O
hold	O
in	O
a	O
relational	B-Application
database	I-Application
,	O
any	O
column	O
in	O
a	O
base	O
table	B-Application
that	O
is	O
declared	O
a	O
foreign	B-Application
key	I-Application
can	O
only	O
contain	O
either	O
null	O
values	O
or	O
values	O
from	O
a	O
parent	O
table	B-Application
's	O
primary	B-Application
key	I-Application
or	O
a	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
In	O
other	O
words	O
,	O
when	O
a	O
foreign	B-Application
key	I-Application
value	O
is	O
used	O
it	O
must	O
reference	O
a	O
valid	O
,	O
existing	O
primary	B-Application
key	I-Application
in	O
the	O
parent	O
table	B-Application
.	O
</s>
<s>
For	O
instance	O
,	O
deleting	O
a	O
record	O
that	O
contains	O
a	O
value	O
referred	O
to	O
by	O
a	O
foreign	B-Application
key	I-Application
in	O
another	O
table	B-Application
would	O
break	O
referential	B-General_Concept
integrity	I-General_Concept
.	O
</s>
<s>
Some	O
relational	B-Application
database	I-Application
management	I-Application
systems	I-Application
(	O
RDBMS	O
)	O
can	O
enforce	O
referential	B-General_Concept
integrity	I-General_Concept
,	O
normally	O
either	O
by	O
deleting	O
the	O
foreign	B-Application
key	I-Application
rows	O
as	O
well	O
to	O
maintain	O
integrity	O
,	O
or	O
by	O
returning	O
an	O
error	O
and	O
not	O
performing	O
the	O
delete	B-Language
.	O
</s>
<s>
Which	O
method	O
is	O
used	O
may	O
be	O
determined	O
by	O
a	O
referential	B-General_Concept
integrity	I-General_Concept
constraint	O
defined	O
in	O
a	O
data	B-Application
dictionary	I-Application
.	O
</s>
<s>
The	O
adjective	O
'	O
referential	O
 '	O
describes	O
the	O
action	O
that	O
a	O
foreign	B-Application
key	I-Application
performs	O
,	O
'	O
referring	O
 '	O
to	O
a	O
linked	O
column	O
in	O
another	O
table	B-Application
.	O
</s>
<s>
In	O
simple	O
terms	O
,	O
'	O
referential	B-General_Concept
integrity	I-General_Concept
 '	O
guarantees	O
that	O
the	O
target	O
'	O
referred	O
 '	O
to	O
will	O
be	O
found	O
.	O
</s>
<s>
A	O
lack	O
of	O
referential	B-General_Concept
integrity	I-General_Concept
in	O
a	O
database	O
can	O
lead	O
relational	B-Application
databases	I-Application
to	O
return	O
incomplete	O
data	O
,	O
usually	O
with	O
no	O
indication	O
of	O
an	O
error	O
.	O
</s>
<s>
It	O
implies	O
that	O
the	O
tuples	B-Application
of	O
values	O
appearing	O
in	O
columns	O
for	O
facts	O
of	O
must	O
also	O
appear	O
as	O
a	O
tuple	B-Application
of	O
values	O
in	O
columns	O
for	O
some	O
fact	O
of	O
.	O
</s>
<s>
Such	O
constraint	O
is	O
a	O
particular	O
form	O
of	O
tuple-generating	O
dependency	O
(	O
TGD	O
)	O
where	O
in	O
both	O
the	O
sides	O
of	O
the	O
rule	O
there	O
is	O
only	O
one	O
relational	O
atom	O
.	O
</s>
<s>
The	O
problem	O
can	O
be	O
shown	O
to	O
be	O
PSPACE-complete	O
by	O
reduction	O
from	O
the	O
acceptance	O
problem	O
for	O
a	O
linear	B-Application
bounded	I-Application
automaton	I-Application
.	O
</s>
<s>
However	O
,	O
logical	O
implication	O
between	O
dependencies	O
that	O
can	O
be	O
inclusion	O
dependencies	O
or	O
functional	B-Application
dependencies	I-Application
is	O
undecidable	O
by	O
reduction	O
from	O
the	O
word	O
problem	O
for	O
monoids	O
.	O
</s>
<s>
Declarative	O
Referential	B-General_Concept
Integrity	I-General_Concept
(	O
DRI	O
)	O
is	O
one	O
of	O
the	O
techniques	O
in	O
the	O
SQL	B-Language
database	I-Language
programming	O
language	O
to	O
ensure	O
data	O
integrity	O
.	O
</s>
<s>
A	O
table	B-Application
(	O
called	O
the	O
referencing	O
table	B-Application
)	O
can	O
refer	O
to	O
a	O
column	O
(	O
or	O
a	O
group	O
of	O
columns	O
)	O
in	O
another	O
table	B-Application
(	O
the	O
referenced	O
table	B-Application
)	O
by	O
using	O
a	O
foreign	B-Application
key	I-Application
.	O
</s>
<s>
The	O
referenced	O
column(s )	O
in	O
the	O
referenced	O
table	B-Application
must	O
be	O
under	O
a	O
unique	O
constraint	O
,	O
such	O
as	O
a	O
primary	B-Application
key	I-Application
.	O
</s>
<s>
Also	O
,	O
self-references	O
are	O
possible	O
(	O
not	O
fully	O
implemented	O
in	O
MS	B-Application
SQL	I-Application
Server	I-Application
though	O
)	O
.	O
</s>
<s>
On	O
inserting	B-Language
a	O
new	O
row	B-Application
into	O
the	O
referencing	O
table	B-Application
,	O
the	O
relational	B-Application
database	I-Application
management	I-Application
system	I-Application
(	O
RDBMS	O
)	O
checks	O
if	O
the	O
entered	O
key	O
value	O
exists	O
in	O
the	O
referenced	O
table	B-Application
.	O
</s>
<s>
If	O
not	O
,	O
no	O
insert	B-Language
is	O
possible	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
specify	O
DRI	O
actions	O
on	O
UPDATE	B-Language
and	O
DELETE	B-Language
,	O
such	O
as	O
CASCADE	O
(	O
forwards	O
a	O
change/delete	O
in	O
the	O
referenced	O
table	B-Application
to	O
the	O
referencing	O
tables	O
)	O
,	O
NO	O
ACTION	O
(	O
if	O
the	O
specific	O
row	B-Application
is	O
referenced	O
,	O
changing	O
the	O
key	O
is	O
not	O
allowed	O
)	O
or	O
SET	O
NULL	O
/	O
SET	O
DEFAULT	O
(	O
a	O
changed/deleted	O
key	O
in	O
the	O
referenced	O
table	B-Application
results	O
in	O
setting	O
the	O
referencing	O
values	O
to	O
NULL	O
or	O
to	O
the	O
DEFAULT	O
value	O
if	O
one	O
is	O
specified	O
)	O
.	O
</s>
<s>
In	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
the	O
term	O
DRI	O
also	O
applies	O
to	O
the	O
assigning	O
of	O
permissions	O
to	O
users	O
on	O
a	O
database	O
object	O
.	O
</s>
<s>
Giving	O
DRI	O
permission	O
to	O
a	O
database	O
user	O
allows	O
them	O
to	O
add	O
foreign	B-Application
key	I-Application
constraints	I-Application
on	O
a	O
table	B-Application
.	O
</s>
