# Re: [HACKERS] [PATCHES] Adding fulldisjunctions to the contrib

```On Friday 11 August 2006 07:18, Bruce Momjian wrote:
> I have looked over this addition, and I think I finally understand it.
> Given three tables, A, B, C, which join as A->B, B->C, C->A, you can
> really join them as A->B->C, and A->C->B.  What full disjunction does is
> to perform both of those joins, and return a one row for each join. Here```
```
What it does is to return all the possible natural joins, i.e.:
A
B
C
A,B
A,C
...
A,B,C

And, it removes any redundant information so that if we have a tuple
Also, note that the full disjunction algorithm i implemented
is commonly used in cases where the scheme graph is cyclic
and thus, you cannot use natural full outer join
to compute the FD.

Finally, you can FD(A,B,C,D,...) any number of relations (limited to 32 in
the implementation) with no regard to the order between them.

A case study and comparison can be found here:
http://www.technion.ac.il/~tzahi/soc.html

> is an example from the README:
>
>     Example of an input and output of a full disjunctions:
>     INPUT:
>
>         --A---|---B---|---C--
>         X---Y-|-Y---Z-|-X---Z
>         a-|-b-|-b-|-c-|-a-|-d
>
>     A,B and C are relations. X,Y and Z are attributes. a,b,c and d are
> values.
>
>     Note that A,B and C are connected in a cycle. That is:
>     A is connected to B on attribute Y,
>     B is connected to C on attribute Z,
>     C is connected to A on attribute X.
>
>     The output of the full disjunctions FD(A,B,C):
>
>            FD
>         X---Y---Z
>         a-|-b-|-c
>         a-|-b-|-d
>
> This code is pretty complex, so I can see why it should be in /contrib.
> Are there reasonable use cases for this capability?
>
> ---------------------------------------------------------------------------
>
> > Hi,
> > I wish to add the fulldisjunctions function to the contrib.
> > With the help of Jonah, we (or rather he :) created a patch with
> > regression tests. The function is finished programmatically but
> > still a little more code documentation touches and improved error
> > messages are needed. All the rest was extensively tested.
> >
> > Attached is the patch.
> >
> > Works great. Just compiled from a fresh cvs which i patched with the
> > attached diff. ran the fulldijsjunction.sql in the
> > share/contrib/fulldisjunction and let it run and it works great.
> > 10x.
> >
> > --
> > Regards,
> > ????????Tzahi.
> > --
> > Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
> > WARNING TO SPAMMERS: ?see at
> > http://members.lycos.co.uk/my2nis/spamwarning.html
>
> [ Attachment, skipping... ]
>
> > TIP 3: Have you checked our extensive FAQ?
> >
> >                http://www.postgresql.org/docs/faq

--
Regards,
Tzahi.
--