Distributivity of projection in relational algebra

864 Views Asked by At

Does a projection distribute over set difference in relational algebra:

in other words does$$\Pi_a (A-B) = \Pi_aA - \Pi_aB$$

where projection is defined as projecting to a subset of attributes from a relation. For example if we have a relation STUDENTS(name, grade, major), we can project onto the subset of attributes that we are interested in (return a table with the instances from STUDENTS but only the columns that we are projecting on).

1

There are 1 best solutions below

0
On BEST ANSWER

If $A$ is a subset of the domain of a function $f,$ then $f(A)$ is defined as $\{f(x) : x \in A\}.$

Extending this familiar and convenient abuse of notation, we could denote the projection of an tuple $t$ on a set of attributes $a$ by $\Pi_a(t);$ and then, if $A$ is a set of tuples, $$ \Pi_a(A) = \{\Pi_a(t) : t \in A\}. $$

It is not generally true that $$ f(A - B) = f(A) - f(B). $$ In particular, if $f$ is a constant function, and $A, B,$ and $A - B$ are all non-empty, then this equation is false.

This general recipe for a counterexample applies in particular to functions of the form $\Pi_a.$ I leave the details to you, except to say that a simple example might involve two students named Harry and Hermione who are both very good at Potions. :)