Sha256: 1ce1b20e88a7ec2277b25a2b086f82be3da48dfc23b8fea3fe5f69dd8b9716c0

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# Image

Extend the left operand with a new relation-valued attribute, image of the
tuple in the right relation.

## Signature

image(left: Relation, right: Relation, as: AttrName) -> Relation

## Examples

image(suppliers, supplies, :supplying)

## Description

This operator extends each tuple of the left operand, say `t`, with a new
attribute called `as`. The latter is a relation-valued attribute, and is the
image of `t` with respect to the right relation. The image is defined as a
restriction-projection: restriction on tuples that match `t` and projection
on all but common attributes between left and right.

In other words, this operator is a shortcut for the following longer
expression:

def image(left, right, as)
  extend(left, as => ->(t){
    allbut(
      matching(right, Relation(t)),
      left.attr_list & right.attr_list)
  })
end
image(suppliers, supplies, :supplying)

Note that the image operator is such that every tuple of the left operand
appears in the result, including those whose image is empty on right. As
expected, an empty relation of correct relation type is used for those.

## Implementation notes

As of current Alf version, the current SQL compilation is not optimal and
partly relies on in-memory operations. Please check the compilation plans.

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-shell-0.16.4 doc/txt/image.txt
alf-shell-0.16.3 doc/txt/image.txt
alf-shell-0.16.2 doc/txt/image.txt
alf-shell-0.16.1 doc/txt/image.txt
alf-shell-0.16.0 doc/txt/image.txt