boolean binary operator. It can be rewritten as
create table
t
1
as
select f
(
A
2
),
V
from
L
2
where
P
1
2
group by
V
select
···
from
L
1
,
t
1
where
P
1
and
P
2
2
and
A
1
op
t
1
.
A
2
where
P
1
2
contains predicates in
P
2
without selections involving
correlation variables, and
P
2
2
introduces the selections involving the
correlation variables. V contains all the attributes that are used in
the selections involving correlation variables in the nested query.
13.14
The set version of the semijoin operator
⋉
is deFned as follows:
r
⋉
H
s
=
P
R
(
r
a
H
s
)
where
R
is the set of attributes in the schema of
r
. The multiset version of
the semijoin operation returns the same set of tuples, but each tuple has
exactly as many copies as it had in
r
.
Consider the nested query we saw in Section 13.4.4 which Fnds the names
of all instructors who taught a course in 2007. Write the query in relational
algebra using the multiset semjoin operation, ensuring that the number
of duplicates of each name is the same as in the SQL query. (The semijoin
operation is widely used for decorrelation of nested queries.)
Answer:
The query can be written as follows:
instructor
⋉
instructor
.
I D
=
teaches
.
I D
(
h
year
=
2007
(
teaches
))
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '13
 Dr.Khansari
 right hand

Click to edit the document details