Relational Algebra equivalent of SQL “NOT IN”
Is there a relational algebra equivalent of the SQL expression NOT IN ? For example if I have the relation: A1 | A2 ---------- x | y a | b y | x I want to remove all tuples in the relation for which A1 is in A2. In SQL I might query: SELECT * FROM R WHERE R.A1 NOT IN ( SELECT A2 FROM R ) / What is really stumping me is how to subquery inside the relational algebra selection operator, is this possible?: σ some subquery here R In relational algebra, you can do this using a carthesian product. Something like: R - ρ a1,a2 (π a11,a21 (σ A11 = A22 (ρ a11,a21 (R) x ρ a12, a22 (R)))) rename the