Relation R(A, B) contains tuples (1,x), (1,y) and (2,x). How many tuples are in the relational algebra result of projection on A, written pi_A(R)?
Correct answer B. 2
Explanation
Relational algebra works on sets, so projection keeps only the requested attributes and removes duplicate tuples. Projecting on A gives the values 1, 1 and 2, which collapse to {1, 2}: two tuples. The answer 3 is what SQL returns for SELECT A FROM R, because SQL tables are multisets and keep duplicates unless you write SELECT DISTINCT.
Answer checked How we write and check questions
Discussion