<s>
Tuple	B-Application
calculus	I-Application
is	O
a	O
calculus	O
that	O
was	O
created	O
and	O
introduced	O
by	O
Edgar	O
F	O
.	O
Codd	O
as	O
part	O
of	O
the	O
relational	B-Architecture
model	I-Architecture
,	O
in	O
order	O
to	O
provide	O
a	O
declarative	O
database-query	O
language	O
for	O
data	O
manipulation	O
in	O
this	O
data	B-Application
model	I-Application
.	O
</s>
<s>
It	O
formed	O
the	O
inspiration	O
for	O
the	O
database-query	O
languages	O
QUEL	B-Language
and	O
SQL	B-Language
,	O
of	O
which	O
the	O
latter	O
,	O
although	O
far	O
less	O
faithful	O
to	O
the	O
original	O
relational	B-Architecture
model	I-Architecture
and	O
calculus	O
,	O
is	O
now	O
the	O
de	O
facto	O
standard	O
database-query	O
language	O
;	O
a	O
dialect	O
of	O
SQL	B-Language
is	O
used	O
by	O
nearly	O
every	O
relational-database-management	B-Application
system	I-Application
.	O
</s>
<s>
Michel	O
Lacroix	O
and	O
Alain	O
Pirotte	O
proposed	O
domain	B-Application
calculus	I-Application
,	O
which	O
is	O
closer	O
to	O
first-order	O
logic	O
and	O
together	O
with	O
Codd	O
showed	O
that	O
both	O
of	O
these	O
calculi	O
(	O
as	O
well	O
as	O
relational	B-Algorithm
algebra	I-Algorithm
)	O
are	O
equivalent	O
in	O
expressive	O
power	O
.	O
</s>
<s>
Subsequently	O
,	O
query	O
languages	O
for	O
the	O
relational	B-Architecture
model	I-Architecture
were	O
called	O
relationally	O
complete	O
if	O
they	O
could	O
express	O
at	O
least	O
all	O
of	O
these	O
queries	O
.	O
</s>
<s>
Since	O
the	O
calculus	O
is	O
a	O
query	O
language	O
for	O
relational	B-Application
databases	I-Application
we	O
first	O
have	O
to	O
define	O
a	O
relational	B-Application
database	I-Application
.	O
</s>
<s>
The	O
basic	O
relational	O
building	O
block	O
is	O
the	O
domain	B-Application
(	O
somewhat	O
similar	O
,	O
but	O
not	O
equal	O
to	O
,	O
a	O
data	O
type	O
)	O
.	O
</s>
<s>
A	O
tuple	B-Application
is	O
a	O
finite	O
sequence	O
of	O
attributes	O
,	O
which	O
are	O
ordered	O
pairs	O
of	O
domains	O
and	O
values	O
.	O
</s>
<s>
A	O
relation	B-Architecture
is	O
a	O
set	O
of	O
(	O
compatible	O
)	O
tuples	B-Application
.	O
</s>
<s>
A	O
table	B-Application
is	O
an	O
accepted	O
visual	O
representation	O
of	O
a	O
relation	B-Architecture
;	O
a	O
tuple	B-Application
is	O
similar	O
to	O
the	O
concept	O
of	O
a	O
row	B-Application
.	O
</s>
<s>
a	O
function	O
that	O
associates	O
a	O
header	O
with	O
each	O
relation	B-Architecture
name	O
in	O
R	O
.	O
(	O
Note	O
that	O
this	O
is	O
a	O
simplification	O
from	O
the	O
full	O
relational	B-Architecture
model	I-Architecture
where	O
there	O
is	O
more	O
than	O
one	O
domain	B-Application
and	O
a	O
header	O
is	O
not	O
just	O
a	O
set	O
of	O
column	O
names	O
but	O
also	O
maps	O
these	O
column	O
names	O
to	O
a	O
domain	B-Application
.	O
)	O
</s>
<s>
Given	O
a	O
domain	B-Application
D	O
we	O
define	O
a	O
tuple	B-Application
over	O
D	O
as	O
a	O
partial	B-Algorithm
function	I-Algorithm
that	O
maps	O
some	O
column	O
names	O
to	O
an	O
atomic	O
value	O
in	O
D	O
.	O
An	O
example	O
would	O
be	O
(	O
name	O
:	O
"	O
Harry	O
"	O
,	O
age	O
:	O
25	O
)	O
.	O
</s>
<s>
The	O
set	O
of	O
all	O
tuples	B-Application
over	O
D	O
is	O
denoted	O
as	O
TD	O
.	O
</s>
<s>
The	O
subset	O
of	O
C	O
for	O
which	O
a	O
tuple	B-Application
t	O
is	O
defined	O
is	O
called	O
the	O
domain	B-Application
of	O
t	O
(	O
not	O
to	O
be	O
confused	O
with	O
the	O
domain	B-Application
in	O
the	O
schema	O
)	O
and	O
denoted	O
as	O
dom(t )	O
.	O
</s>
<s>
The	O
latter	O
requirement	O
simply	O
says	O
that	O
all	O
the	O
tuples	B-Application
in	O
a	O
relation	B-Architecture
should	O
contain	O
the	O
same	O
column	O
names	O
,	O
namely	O
those	O
defined	O
for	O
it	O
in	O
the	O
schema	O
.	O
</s>
<s>
For	O
the	O
construction	O
of	O
the	O
formulas	O
we	O
will	O
assume	O
an	O
infinite	O
set	O
V	O
of	O
tuple	B-Application
variables	O
.	O
</s>
<s>
The	O
formulas	O
are	O
defined	O
given	O
a	O
database	O
schema	O
S	O
=	O
(	O
D	O
,	O
R	O
,	O
h	O
)	O
and	O
a	O
partial	B-Algorithm
function	I-Algorithm
type	O
:	O
V	O
⇸	B-Algorithm
2C	O
,	O
called	O
at	O
type	O
assignment	O
,	O
that	O
assigns	O
headers	O
to	O
some	O
tuple	B-Application
variables	O
.	O
</s>
<s>
We	O
then	O
define	O
the	O
set	O
of	O
atomic	B-Algorithm
formulas	I-Algorithm
A[S,type]	O
with	O
the	O
following	O
rules	O
:	O
</s>
<s>
Book(t )	O
—	O
tuple	B-Application
t	O
is	O
present	O
in	O
relation	B-Architecture
Book	O
.	O
</s>
<s>
The	O
formal	O
semantics	O
of	O
such	O
atoms	O
is	O
defined	O
given	O
a	O
database	O
db	O
over	O
S	O
and	O
a	O
tuple	B-Application
variable	O
binding	O
val	O
:	O
V	O
→	O
TD	O
that	O
maps	O
tuple	B-Application
variables	O
to	O
tuples	B-Application
over	O
the	O
domain	B-Application
in	O
S	O
:	O
</s>
<s>
Date	O
have	O
as	O
their	O
subject	O
the	O
relational	B-Architecture
model	I-Architecture
.	O
</s>
<s>
We	O
will	O
assume	O
that	O
the	O
quantifiers	O
quantify	O
over	O
the	O
universe	O
of	O
all	O
tuples	B-Application
over	O
the	O
domain	B-Application
in	O
the	O
schema	O
.	O
</s>
<s>
This	O
leads	O
to	O
the	O
following	O
formal	O
semantics	O
for	O
formulas	O
given	O
a	O
database	O
db	O
over	O
S	O
and	O
a	O
tuple	B-Application
variable	O
binding	O
val	O
:	O
V	O
->	O
TD	O
:	O
</s>
<s>
∀	O
v	O
:	O
H	O
(	O
f	O
)	O
is	O
true	O
if	O
and	O
only	O
if	O
for	O
all	O
tuples	B-Application
t	O
over	O
D	O
such	O
that	O
dom(t )	O
=	O
H	O
the	O
formula	O
f	O
is	O
true	O
for	O
val[v->t]	O
.	O
</s>
<s>
where	O
v	O
is	O
a	O
tuple	B-Application
variable	O
,	O
H	O
a	O
header	O
and	O
f(v )	O
a	O
formula	O
in	O
F[S,type]	O
where	O
type	O
=	O
{	O
(	O
v	O
,	O
H	O
)	O
}	O
and	O
with	O
v	O
as	O
its	O
only	O
free	O
variable	O
.	O
</s>
<s>
The	O
result	O
of	O
such	O
a	O
query	O
for	O
a	O
given	O
database	O
db	O
over	O
S	O
is	O
the	O
set	O
of	O
all	O
tuples	B-Application
t	O
over	O
D	O
with	O
dom(t )	O
=	O
H	O
such	O
that	O
f	O
is	O
true	O
for	O
db	O
and	O
val	O
=	O
{	O
(	O
v	O
,	O
t	O
)	O
}	O
.	O
</s>
<s>
Because	O
the	O
semantics	O
of	O
the	O
quantifiers	O
is	O
such	O
that	O
they	O
quantify	O
over	O
all	O
the	O
tuples	B-Application
over	O
the	O
domain	B-Application
in	O
the	O
schema	O
it	O
can	O
be	O
that	O
a	O
query	O
may	O
return	O
a	O
different	O
result	O
for	O
a	O
certain	O
database	O
if	O
another	O
schema	O
is	O
presumed	O
.	O
</s>
<s>
For	O
example	O
,	O
consider	O
the	O
two	O
schemas	O
S1	O
=	O
(	O
D1	O
,	O
R	O
,	O
h	O
)	O
and	O
S2	O
=	O
(	O
D2	O
,	O
R	O
,	O
h	O
)	O
with	O
domains	O
D1	O
=	O
{	O
1	O
}	O
,	O
D2	O
=	O
{	O
1	O
,	O
2	O
}	O
,	O
relation	B-Architecture
names	O
R	O
=	O
{	O
"	O
r1	O
"	O
}	O
and	O
headers	O
h	O
=	O
{	O
(	O
"	O
r1	O
"	O
,	O
 { "a" } 	O
)	O
}	O
.	O
</s>
<s>
It	O
will	O
also	O
be	O
clear	O
that	O
if	O
we	O
take	O
the	O
domain	B-Application
to	O
be	O
an	O
infinite	O
set	O
,	O
then	O
the	O
result	O
of	O
the	O
query	O
will	O
also	O
be	O
infinite	O
.	O
</s>
<s>
To	O
solve	O
these	O
problems	O
we	O
will	O
restrict	O
our	O
attention	O
to	O
those	O
queries	O
that	O
are	O
domain	B-Application
independent	O
,	O
i.e.	O
,	O
the	O
queries	O
that	O
return	O
the	O
same	O
result	O
for	O
a	O
database	O
under	O
all	O
of	O
its	O
schemas	O
.	O
</s>
<s>
An	O
interesting	O
property	O
of	O
these	O
queries	O
is	O
that	O
if	O
we	O
assume	O
that	O
the	O
tuple	B-Application
variables	O
range	O
over	O
tuples	B-Application
over	O
the	O
so-called	O
active	O
domain	B-Application
of	O
the	O
database	O
,	O
which	O
is	O
the	O
subset	O
of	O
the	O
domain	B-Application
that	O
occurs	O
in	O
at	O
least	O
one	O
tuple	B-Application
in	O
the	O
database	O
or	O
in	O
the	O
query	O
expression	O
,	O
then	O
the	O
semantics	O
of	O
the	O
query	O
expressions	O
does	O
not	O
change	O
.	O
</s>
<s>
In	O
fact	O
,	O
in	O
many	O
definitions	O
of	O
the	O
tuple	B-Application
calculus	I-Application
this	O
is	O
how	O
the	O
semantics	O
of	O
the	O
quantifiers	O
is	O
defined	O
,	O
which	O
makes	O
all	O
queries	O
by	O
definition	O
domain	B-Application
independent	O
.	O
</s>
<s>
In	O
order	O
to	O
limit	O
the	O
query	O
expressions	O
such	O
that	O
they	O
express	O
only	O
domain-independent	O
queries	O
a	O
syntactical	O
notion	O
of	O
safe	O
query	O
is	O
usually	O
introduced	O
.	O
</s>
<s>
The	O
first	O
is	O
whether	O
a	O
variable-column	O
pair	O
t.a	O
is	O
bound	O
to	O
the	O
column	O
of	O
a	O
relation	B-Architecture
or	O
a	O
constant	O
,	O
and	O
the	O
second	O
is	O
whether	O
two	O
variable-column	O
pairs	O
are	O
directly	O
or	O
indirectly	O
equated	O
(	O
denoted	O
t.v	O
==	O
s.w	O
)	O
.	O
</s>
<s>
The	O
restriction	O
to	O
safe	O
query	O
expressions	O
does	O
not	O
limit	O
the	O
expressiveness	O
since	O
all	O
domain-independent	O
queries	O
that	O
could	O
be	O
expressed	O
can	O
also	O
be	O
expressed	O
by	O
a	O
safe	O
query	O
expression	O
.	O
</s>
<s>
This	O
can	O
be	O
proven	O
by	O
showing	O
that	O
for	O
a	O
schema	O
S	O
=	O
(	O
D	O
,	O
R	O
,	O
h	O
)	O
,	O
a	O
given	O
set	O
K	O
of	O
constants	O
in	O
the	O
query	O
expression	O
,	O
a	O
tuple	B-Application
variable	O
v	O
and	O
a	O
header	O
H	O
we	O
can	O
construct	O
a	O
safe	O
formula	O
for	O
every	O
pair	O
v.a	O
with	O
a	O
in	O
H	O
that	O
states	O
that	O
its	O
value	O
is	O
in	O
the	O
active	O
domain	B-Application
.	O
</s>
<s>
Effectively	O
this	O
means	O
that	O
we	O
let	O
all	O
variables	O
range	O
over	O
the	O
active	O
domain	B-Application
,	O
which	O
,	O
as	O
was	O
already	O
explained	O
,	O
does	O
not	O
change	O
the	O
semantics	O
if	O
the	O
expressed	O
query	O
is	O
domain	B-Application
independent	O
.	O
</s>
