- Inserted comments to explain what happens in the division

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@241 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-07-02 14:49:24 +07:00
parent 45af67f241
commit 36fd7af8fd
1 changed files with 18 additions and 3 deletions

@ -238,11 +238,26 @@ class relation (object):
header of S, for which it holds that all their combinations with tuples
in S are present in R.
'''
#d_headers are the headers from self that aren't also headers in other
d_headers=list(set(self.header.attributes) - set(other.header.attributes))
'''
Wikipedia defines the division as follows:
a1,....,an are the d_headers
T := πa1,...,an(R) × S
U := T - R
V := πa1,...,an(U)
W := πa1,...,an(R) - V
W is the result that we want
'''
t=self.projection(d_headers).product(other)
u = t.difference(self)
v = u.projection(d_headers)
return self.projection(d_headers).difference(v)
return self.projection(d_headers).difference(t.difference(self).projection(d_headers))
def union(self,other):
'''Union operation. The result will contain items present in first