Native Relational Operations (Cont.)


Division
Assume Head(R)=A1…An B1…Bm, and Head(S)=B1…Bm. The table T is the result of the division R÷S if Head(T)=A1…An and T contains exactly those rows t such that for every row s in S, the row resulting from concatenating t and s can be found in table R.

R
A B C
a1 b1 c1
a2 b1 c1
a1 b2 c1
a1 b2 c2
a2 b1 c2
a1 b2 c3
a1 b2 c4
a1 b1 c5
S1
C
c1

T1:=R÷S1
T1
A B
a1 b1
a2 b1
a1 b2

S2
B C
b1 c1

T2:=R÷S2
T2
A
a1
a2

Given T=R÷S, it is not always true that R=T×S. However, T contains the largest possible set of rows such that T×S⊆R.

Query: List product numbers for products ordered by customer c006.
PC6 := (ORDER where cid='c006')[pid]
PC6
pid
p01
p07

Query: Find the customers have placed orders for all these products.
CP := ORDER[cid, pid]
T := CP ÷ PC6
T
cid
c001
c006



      A dream doesn’t become reality through magic;    
      it takes sweat, determination and hard work.    
      — Colin Powell