Intuition for a projection in tuple relational calculus

Let's have a relation $$R = (name, surname, age)$$. I want to obtain a new relation with only the $$name$$ attribute. In relational algebra I would simply do $$\Pi_{\mathrm{name}}(R)$$ but in relational calculus the general way of doing that is $$\newcommand{\Set}[2]{% \{\, #1 \mid #2 \, \}% } \Set{t}{\exists z \; (R(z) \land t.\mathrm{name} = z.\mathrm{name}}.$$

How does it work? I thought that relation is basically a table and tuple is a row from that table. How does this expression retrieve the original relation with only the name as an attribute?

If I don't specify where the tuple variable $$t$$ belongs to, we're ranging over all tuples $$t$$ from the schema right?

1. How can a tuple be just a slice of a table?

2. Take a tuple from $$R$$ that contains $$name$$, $$surname$$ and $$age$$. It also follows the rule that $$t.\mathrm{name} = z.\mathrm{name}$$ doesn't it? How come it doesn't show up in the result? I'm so confused.

Note: in the following I assume that a tuple has a fixed set of values, and its order is significant: in other words, if R(a, b) has a tuple t1 = (2, 4), then t1.a = 2 and t1.b = 4.

The basic idea behind the tuple relational calculus is that each relation represents a certain predicate, and a relation extension (the tuples) represents a model (i.e. a set of objects) that makes true such predicate. So for instance if R in your example has only three tuples,

("John", "Rean", 19)
("Mary", "Rean", 24)
("Mary", "June", 18)


this means that it is true that John Rean, Mary Rean, and Mary June satisfy the predicate R, and only them.

A query is expressed as a (well-formed) first order formula, and its “result” is obtained by finding in the model the objects that, substituted to the free variables of the formula, make it true.

So the query:

{t | P(t) }

means: the set of tuples t that satisfy the predicate P (remember that we want always, as result, a set of tuples, that is a relation).

So, in your example, the formula:

{𝑡 ∣ ∃𝑧(𝑅(𝑧) ∧ 𝑡.name = 𝑧.name}


means: “all the tuples t for which exists at least a tuple true for R with the same name of t”; in other words, all the tuples that have a name among the names of the tuples model of R. So, note that if we have more than one tuple with the same name, in the result we will have only a tuple with such name.

Remember that we are looking for all the possible tuples that can be retrieved by the model that makes the predicate true: this means that we are looking for all the tuples such that:

∃𝑧(𝑅(𝑧) ∧ 𝑡.name = 𝑧.name)


is true. And so there are two and only two tuples that satisfy this predicate:

("John")
("Mary")


so this is the result of our query (note that we assume that a tuple returned has only the "fields" mentioned in its predicate, so t has only the “field” name).

• note that we assume that a tuple returned has only the "fields" mentioned in its predicate is the problem - is this true by definition? If we do not specify to which relation a tuple $t$ belongs we only retrieve tuples $t$ with the fields mentioned iby $t.field$, right? My point was that ("Mary"), ("Mary", "Rean"), ("Mary", "Rean", 24), ("Mary", "June"), ("Mary", "June", 18), ("Mary", 18), ("Mary", 24), ("John", "Rean", 19), ("John", "Rean"), ("John"), ("John", 19) are all the tuples that seem to satisfy the given predicate and they could form a relation containing any combination of columns Sep 28 at 16:14
• t does not belong to any relation. It is a set of tuples such that the following defining predicate is true. So, if the predicate mentions only certain fields, then the tuples t have only those field. I have seen also notations in which the type of t is specified (something like t:<name:string> | ..., but this is not a common notation. So, we could say that this fact (the tuples has only the component specified in the predicate) is implicitly true by definition. Sep 28 at 16:19
• See for instance in wikipedia the two examples, t:{field-name}. Sep 28 at 16:24