Database Reference
In-Depth Information
Table 6.1
SQL translations
Embedded SQL statements: 'EXEC t'
Embedded (internal) algebra statements
t
=
'SELECT...'
t
S
∈
T
P
X
in
Σ
R
⊂
Σ
RE
∈
T
P
X
in
Σ
R
⊂
t
=
'DELETE FROM
r
WHERE C'
t
D
Σ
RE
(i)
t
=
'INSERT INTO
r
[
S
]
VALUES (list)'
t
I
∈
T
RE
X
(ii)
t
=
'INSERT INTO
r
[
S
]
AS SELECT...'
t
I
∈
T
P
X
t
=
'UPDATE
r
SET
t
U
∈
T
RE
X
[
nr
r
(i
1
)
=
e
i
1
,...,nr
r
(i
k
)
=
e
i
k
]
WHERE
C
'
t
=
'EXTEND
r
ADD
a,name
AS
e
'
idem,
t
E
=
t
∈
T
RE
X
will be executed the instruction 'CALL
n
' from host
M
U
by passing such a
list of values to
M
R
.
The
k
=|
S
|≤
ar(r)
has to be equal to the number of values in the list in
the case (1), or to the
ar(
t
S
#
)
in case (ii).
4.
t
U
=
C)
UNION
r
1
', where
r
1
is a relation expressed by
EXTEND
...
EXTEND
(r
WHERE
C)
ADD
att
r
(
1
), name
1
AS
e
1
...
ADD
att
r
(n),name
n
AS
e
n
[
'
(r
WHERE
¬
S
]
,
and for each 1
≤
m
≤
n
=
ar(r)
if
m/
∈{
i
1
,...,i
k
}
then
e
m
=
nr
r
(m)
, and
S
=
.
Notice that in SQL each expression
e
m
,
m
name
1
,...,name
n
,isasimple
value
in
dom
. However, after the
Bind
module, these values in the embedded (inter-
nal) algebra statements are treated as the variables: the assignment of values
to them will be done during the execution of the program
P
when executing
the instruction 'CALL
n
' from host
M
U
by passing such a list of values to
M
R
.
Analogously, all constants used in 'SELECT...' or in the conditions 'C',
will be substituted by new fresh variables, and their assignment will be done
during the execution of a program
P
.
5. The
Bind
component compiles one or more related DBRMs to produce an ap-
plication plan (a program for an RDB machine
M
R
) composed principally of
the
normal
forms
Rd
RE
(t
R
)
∈{
i
1
,...,i
k
}
Nrm(Trw(t
R
))
(the arrows in the category
RA
),
obtained from the internal algebra statements
t
R
∈
T
RE
X
after precompilation.
Each normal form formula is a composed
n
-operator of the database machine
M
R
, i.e., exactly a composition of the atomic arrows in
RA
(which are unary
operations in
Σ
RA
\
Σ
RA
in Proposition
20
, Sect.
5.2
), which is an executable
code for this categorial database machine
M
R
. The Bind component executes
the following three steps for any statement
t
R
∈
T
RE
X
in order to obtain a
executable code for
M
R
:
5.1. Executes the term-rewriting algorithm
Trw
=
:
T
RE
X
→
T
RA
X
defined in
Proposition
20
, Sect.
5.2
.