Invert

Relational functions invert

syntax

  • invert(relation)

definition

invert(a) inverts the relation Argument.

Inverting means the resulting Attribute has as Domain unit the Values unit and as values unit the domain unit of the relation argument.

applies to

  • attribute relation with Value type of the group CanBeDomainUnit

performance

O(n) where n = number of elements in the domain of relation. Single pass finding last occurrence of each value. For multiple occurrences per value, see invertAll which builds linked lists in O(n).

value info

For a resulting row that is null, the [[value info]] dialog reports no row of the inverted attribute refers to this row: no element of the relation argument holds that row number. For a row that does have a value, the dialog lists every element of relation that maps onto it, not only the one that was kept — which is how a value dropped because of a duplicate becomes visible. In the example below, row 1 of the result lists both row 1 and row 3 of City/Region_rel. (since 20.16.0)

example

attribute<Region> invertRegion_rel (Region) := invert(City/Region_rel);
City/Region_rel
0
1
2
1
3
null
3

domain City, nr of rows = 7

InvertRegion_rel
0
3
2
6
null

domain Region, nr of rows = 5