Database Reference
In-Depth Information
nr
r
(ar(r
1
)
name
otherwise being a fresh new name for this column; with
the attribute function
atr
r
:{
+
1
)
=
ar(r
1
)
+
1
}→
att
such that
atr
r
(i)
=
atr
r
1
(i)
if
i
≤
ar(r
1
)
and
atr
r
(ar(r
1
)
+
1
)
=
a
otherwise, and
=
∪
d
&
e(
d
)
r
1
,
r
|
d
∈
where
e(
d
)
dom(a)
is a constant or the value obtained from the function
e
where each name
nr
r
(i)
is substituted by the value
d
i
of the tuple
d
∈
=
d
1
,...,d
n
∈
r
1
; in the special cases, we can use nullary functions (constants)
for the expression
e
(for example, for the NULL value).
(note that
r
is empty if
e
is an expression and
r
1
empty as well).
Then, for a nonempty relation
r
1
, the EXTEND
r
1
ADD
a,name
AS
e
(i.e.,
r
1
a,name,e
) can be represented by the following logical equivalence:
⇔
r
1
(x
1
,...,x
n
)
∧
x
n
+
1
=
e(
x
)
,
r(x
1
,...,x
n
+
1
)
where
e(
x
)
is obtained by substituting each
name
i
=
nr
r
1
(j)
(of the
j
th column
of
r
1
) in the expression
e
by the variable
x
j
.
We are able to define a new relation with a single tuple
d
1
,...,d
k
,k
≥
1 with the
given list of attributes
a
1
,...,a
k
, by the following finite length expression,
EXTEND
...(
EXTEND
r
∅
ADD
a
1
, name
1
AS
d
1
)...
ADD
a
k
, name
k
AS
d
k
,
or equivalently, by
r
∅
a
1
, name
1
,d
1
⊗···⊗
r
∅
a
k
, name
k
,d
k
, where
r
∅
is the
empty type relation with
0 introduced in Definition
8
, and empty
functions
atr
r
∅
and
nr
r
∅
. Such single tuple relations can be used for an insertion in
a given relation (with the same list of attributes) in what follows.
r
∅
=⊥
,
ar(r
∅
)
=
Update Operators
The three update operators, 'UPDATE', 'DELETE' and 'IN-
SERT' of the Relational algebra, are derived operators from these previously defined
operators in the following way:
1. Each algebraic formulae 'DELETE FROM
r
WHERE
C
' is equivalent to the
formulae '
r
WHERE
C
', that is, to '
r
MINUS (
r
WHERE
C
)'.
2. Each algebraic expression (a term) 'INSERT INTO
r
¬
[
S
]
VALUES (list of val-
AS SELECT...', is equivalent to '
r
UNION
r
1
'
where the union compatible relation
r
1
is a one-tuple relation (defined by list)
in the first, or a relation defined by 'SELECT...' in the second case.
In the case of a single tuple insertion (version with 'VALUES') into a given
relation
r
, we can define a single tuple relation
r
1
by using 'EXTEND...' oper-
ations.
3. Each algebraic expression 'UPDATE
r
SET
ues)', 'INSERT INTO
r
[
S
]
[
nr
r
(i
1
)
=
e
i
1
,...,nr
r
(i
k
)
=
e
i
k
]
WHERE
C
', for
n
=
ar(r)
, where
e
i
m
,
1
≤
i
m
≤
n
for 1
≤
m
≤
k
are the ex-
pressions and
C
is a condition, is equal to the formula '(
r
WHERE
¬
C
) UNION
r
1
' , where
r
1
is a relation expressed by