Professional Documents
Culture Documents
Relational Calculus (TRC) "All" and "Only" Queries
Relational Calculus (TRC) "All" and "Only" Queries
1
Example: Find sailors who’ve
reserved all red boats (1)
The complement of
The answer set
the answer set
4
Find sailors who’ve reserved all red
boats (4)
5
Find sailors who’ve reserved all red
boats (5)
6
Wrong way: Find sailors who’ve
reserved all red boats (6)
7
Easier: Find sailors who’ve reserved
all boats
{S | S ∈ Sailors ∧ ∀B ∈ Boats
(∃R ∈ Reserves (R.sid = S.sid ∧ R.bid=B.bid))}
8
Find sailors who’ve reserved only red
boats (1)
Sailors for which
Sailors who
there exists a non-
have reserved
red boat they have
only red boats
reserved
10
Find sailors who’ve reserved only red
boats (3)
11
Find sailors who’ve reserved only red
boats (4)
12
Find sailors who’ve reserved only red
boats (5)