I was reading relational algebra from one of the textbook. I came across DIVIDE operation. From Wikipedia:
The division is a binary operation that is written as R ÷ S. The result consists of the restrictions of tuples in R to the attribute names unique to R, i.e., in the header of R but not in the header of S, for which it holds that all their combinations with tuples in S are present in R.
Thus if R is:
+----+----+
| A | B |
+----+----+
| a1 | b1 |
| a2 | b1 |
| a3 | b1 |
| a4 | b1 |
| a1 | b2 |
| a3 | b2 |
| a2 | b3 |
| a3 | b3 |
| a4 | b3 |
| a1 | b4 |
| a2 | b4 |
| a3 | b4 |
+----+----+
and S is:
+----+
| A |
+----+
| a1 |
| a2 |
| a3 |
+----+
then the output should be:
+----+
| B |
+----+
| b1 |
| b4 |
+----+
Now the book gives relational equivalent steps to calculate DIVIDE operations as below. I am trying to immitate it exactly in SQL Server, but out of direction
T1 ← πBR //that is SELECT A FROM R T2 ← πB((S x T1) - R) //SxT1 can simply be done as SELECT * FROM S,T1 T ← T1 - T2