Sha256: 51e379f308746f1611fbfcd5ea23905bccb10fd57f2af62fd2afb56e985cf2c0

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

.TH Minus
.PP
Logical AND NOT
.SH Signature
.PP
.RS
.nf
minus(left: Relation, right: Relation) \-> Relation
.fi
.RE
.SH Examples
.PP
.RS
.nf
minus(
  restrict(suppliers, eq(:city, 'Paris')),
  restrict(suppliers, gt(:status, 10)))
.fi
.RE
.SH Description
.PP
Computes the relation as the set difference of \fB\fCleft\fR and \fB\fCright\fR\&.
.PP
The \fB\fCleft\fR and \fB\fCright\fR relations must be minus\-compatible, which meaning
that they must have same heading (type inheritance is partly supported
through ruby's own type system, so that the actual behavior is slighlty more
permissive).
.SH Implementation notes
.PP
Unlike SQL, this operator ALWAYS remove duplicates. There is no way, in
Alf, to compute \fIbags\fP of tuples and therefore no way to express something
such as SQL's EXCEPT ALL.
.PP
It is sometimes idiomatic in Alf to use \fB\fCintersect\fR as a logical AND NOT, as
illustrated below. So far, the optimizer/compiler is not smart enough to
translate the former into the latter (which is likely to have a better query
plan when using faithful SQL compilation and available SQL DBMSs). Any patch
is welcome here too!
.PP
.RS
.nf
minus(
  restrict(suppliers, eq(:city, 'Paris')),
  restrict(suppliers, gt(:status, 10)))
.fi
.RE
.PP
is equivalent to
.PP
.RS
.nf
restrict(suppliers, eq(:city, 'Paris') & !gt(:status, 10))
.fi
.RE

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alf-shell-0.16.3 doc/man/minus.man
alf-shell-0.16.2 doc/man/minus.man
alf-shell-0.16.1 doc/man/minus.man