From 36fd7af8fda978c88ee8842f9ed6b831b8feb368 Mon Sep 17 00:00:00 2001 From: LtWorf Date: Fri, 2 Jul 2010 14:49:24 +0000 Subject: [PATCH] - 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 --- relational/relation.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/relational/relation.py b/relational/relation.py index 63d4291..6d7e931 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -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