tags:

views:

49

answers:

1

How do I represent a subquery in relation algebra.

Do I put the new select under the previous select condition.

SELECT number
FROM collection
WHERE number = (SELECT anotherNumber FROM anotherStack);
+1  A: 

You would just rewrite that as a join.

I'm not sure how widely used the syntax I learned for Relational Algebra is so in words.

  1. Take a projection of anotherNumber from anotherStack
  2. Rename anotherNumber from the result of step 1 as number
  3. Natural Join the result of step 2 onto collection
  4. Take a final projection of number from the result of step 3
Martin Smith