(apologies for the incorrect tag, there was no relational-calculus tag)

In this lecture video the following tuple-relational calculus formula is given:

$\{ P | \exists S \in \text{Sailors} ( S.\text{rating} > 7 \land P.\text{sname} = S.\text{sname} \land P.\text{age} = S.\text{age}) \}$

in answer to the question Find the names and ages of sailors with rating above 7.

I'm having trouble understanding what the purpose is of the existence and equality operators used here as it wasn't adequately explained. There were several lectures on relational algebra and then only one cursory example on TRC.

My answer looked like this:

$\{ ( S.\text{sname}, S.\text{age} ) | S \in \text{Sailors} ( S.\text{rating} > 7 ) \}$

since we are getting back a set of tuples. I'm not sure why mine is wrong.

Also I've seen some queries where the existential quantifier is used in different places without explanation. For example, for a different question from this PDF:

$\{ S | S \in \text{Sailors} ∧ S.\text{rating} > 7 ∧ ∃R(R∈\text{Reserves} ∧ R.\text{sid} = S.\text{sid} ∧ R.\text{bid} = \text{103})\}$

How is the existential quantifier meant to be used in TRC? When should it be used or not used? Why is it used differently in the two formulas? Why does the first formula above appear to do a join instead of just building the tuples as in my answer? The original question above implies the result will be a projection, which I know is a relational algebra construct, but it seems we should get back a 2-tuple having only those fields. So I'm not clear on how the act of "joining" in the first formula results in a "projection" for the answer.

Any clarification appreciated thanks.


I found the answer in Ramakrishnan text and expanded on the answer in this other question that I couldn't find when I wrote this one.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.