Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

LIST

Use this function to create a list based on a value. It is the inverse of the UNPACK function.

Syntax

Panel
bgColorwhite

UNPACK


Use this function to extract the value from a single valued collection or list. It is the inverse of the LIST function.


Syntax

Code Block
UNPACK ( collection/list )


Input
  • collection/list - A collection or list of one entity or attribute instance.


Return type

  • entity instance
  • attribute value of any type


Examples

Suppose the following data model.


Person.namePerson.SequenceNumber
“Bob”654
“Jane”523
“Mary”667
“Rick”500
“Ron”490
“Jenny”765
  • UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) ) = “Ron”

  • In case a second entry "Ron","490" exists, the expression UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) ) will fail, because the UNPACK cannot resolve a list with two elements. To solve this the UNIQUE function has to be used: UNPACK ( UNIQUE ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) ) ) = "Ron".
  • UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MAX ( COLLECT Person.SequenceNumber FROM ALL Person ) ) ) = “Jenny”

Back to top

Panel
bgColorwhite
Code Block
LIST ( attribute/collection )
Inputs
  • attribute - An attribute of any data type.
  • collection/list - A collection or list of values.

Return type

  • a multivalued list with entries of any type

Examples

ExpressionResultTypeLIST ( "Blueriq" )[ "Blueriq" ]String (multivalued)LIST ( 5 )[ 5 ]Integer (multivalued)LIST ( ? )[]Any (multivalued)

Suppose the following data model.

Person.namePerson.SequenceNumber“Bob”654“Jane”523“Mary”667“Rick”500“Ron”490“Jenny”?
  • LIST ( COLLECT Person.name FROM ALL Person ) = [ "Bob" , "Jane" , "Mary" , "Rick" , "Ron" , "Jenny" ]
    • In this example the LIST function adds no value, as the result of the COLLECT is already a list.
  • LIST ( COLLECT Person.SequenceNumber FROM ALL Person ) = []
    • As Jenny has an unknown sequence number, the result of the COLLECT expression is ?. The LIST function creates an empty list in case the parameter has ? value.

Back to top

Panel
bgColorwhite
AnchorSIZESIZESIZE

This function determines the size of a collection.

Syntax

Code Block
SIZE ( collection )
Inputs
  • collection - A collection of attribute or entity instances. This can be an expression or a relation attribute for instance.

Return type

  • integer

Example

Suppose you have a Parent and a Child entity, where Parent has a multivalued relation with Child via the relation Parent.has_Children. With this model the following instances are created:

Parent instanceChild instanceChild.nameChild.hobbiesParent_1Child_1“Kim”“Reading”, “Dancing”Parent_1Child_2“Rick”“Tennis”, “Dancing”Parent_1Child_3“Bob”“Painting”, “Basketball”, “Reading”Parent_2Child_4“Mary”“Football”

Then:

Active instanceExpressionResultTypeParent_1SIZE ( Parent.has_Children )3IntegerParent_2SIZE ( Parent.has_Children )1IntegernoneSIZE ( Parent.has_Children )ErrorChild_1SIZE ( Child.hobbies )2IntegerChild_3SIZE ( Child.hobbies )3IntegerChild_4SIZE ( Child.hobbies )1IntegerSIZE( ? )0Integer
UI Text Box
typenote

SIZE and COUNT are similar except for ?:

SIZE ( ? ) results in 0, while COUNT ( ? ) results in ?

Back to top

Panel
bgColorwhite

UNIQUE

The UNIQUE function filters duplicate items from a collection. An expression resulting in a collection, never contains duplicate values. A subexpression with the COLLECT statement however, can contain duplicates. See the note on collections and duplicates for more info.

Syntax

Code Block
 UNIQUE ( collection )
Input
  • collection - A collection of attribute or entity instances.

Return type

  • collection

Examples

Suppose the following model.

Person instancePerson.namePerson_1“Kim”Person_2“Rick”Person_3“Bob”Person_4“Rick”ExpressionResultTypeNoteCOLLECT Person.name FROM ALL Person[ "Kim" , "Rick" , "Bob" ]String (multivalued)A result never contains duplicate valuesSIZE ( COLLECT Person.name FROM ALL Person )4IntegerA subexpression can contain duplicate valuesSIZE ( UNIQUE ( COLLECT Person.name FROM ALL Person ) )3IntegerThe collection holds three unique values

Back to top

Panel
bgColorwhite

SUBSET OF

This function returns TRUE if the items in a collection are all present in another collection.

Syntax

Code Block
 collection1 SUBSET OF collection2
Inputs
  • collection1 - The collection that is tested to be a subset of the second collection.
  • collection2 - The collection that is tested to hold all the items in the first collection.

Return type

  • Boolean

Venn diagram

Image Removed

Examples

ExpressionResultTypeNote( 'a' , 'b' , 'c' ) SUBSET OF ( 'a' , 'b' , 'c' , 'd' )TRUEBoolean( 'a' , 'b' , 'c' , 'd' ) SUBSET OF ( 'a' , 'b' , 'c' )FALSEBooleanPerson.hobbies SUBSET OF [ "Tennis" , "Soccer" , "Music" ]
Given Person.hobbies = [ "Tennis" , "Soccer" ]TRUEBooleanPerson.hobbies SUBSET OF [ "Tennis" , "Soccer" , "Music" ]
Given Person.hobbies = [ ? ]?BooleanPerson.hobbies SUBSET OF [ "Tennis" , "Soccer" , ? ]
Given Person.hobbies = [ "Tennis" , "Soccer" ]FALSEBoolean[ "Tennis" , "Soccer" , ? ] evaluates to [ ? ]
Person.hobbies SUBSET OF [ ? ] = FALSE( 'a' , 'b' , 'c' ) SUBSET OF ( [ 'a' , 'b' , 'c' , 'd' ] )Error

1 SUBSET OF Address.Numbers

Given Adress.Numbers = ?

FALSEBoolean
UI Text Box
typenote
Values between single quotes are considered value list items. For backwards compatibility reasons, a comma separated sequence of value list items is treated as a collection. That's why there is no need to enclose the values between square brackets. In fact if you do add the square brackets you create a matrix rather than a list.

Back to top

Panel
bgColorwhite

UNION

Adds two collections of the same base type to a new collection.

Syntax

Code Block
 UNION ( collection1 , collection2 )
Inputs
  • collection1 - First collection to be added to the new collection.
  • collection2 - Second collection to be added to the new collection.

Return type

  • collection

Venn diagram

Image Removed

Examples

Suppose you have a Parent and a Child entity, where Parent has a multivalued relation with Child via the relation Parent.has_Children. With this model the following instances are created:

Parent instanceChild instanceChild.nameChild.hobbiesParent_1Child_1“Kim”“Reading”, “Dancing”Parent_1Child_2“Rick”“Tennis”, “Dancing”Parent_1Child_3“Bob”“Painting”, “Basketball”, “Reading”Parent_2Child_4“Mary”“Football”ExpressionResultTypeUNION ( Parent[Parent_1].has_Children ,
Parent[Parent_2].Has_Children )[ Child_1, Child_2 , Child_3, Child_4 ]Collection of Child instancesUNION ( Parent[Parent_1].has_Children.name ,
Parent[Parent_2].Has_Children.name )[ “Kim”, “Rick”, “Bob”, “Mary” ]String (multivalued)UNION ( Child[Child_2].hobbies , "Reading" )[ “Tennis”, “Dancing”, “Reading” ]String (multivalued)UNION ( Child[Child_1].hobbies , Child[Child_2].hobbies )[ “Reading”, “Dancing”, “Tennis” ]String (multivalued)UNION( ?, [1, 2] )UNKNOWNInteger (multivalued)

Back to top

Panel
bgColorwhite

INTERSECTION

This function determines the intersection of two collections. It returns a collection containing the items that are present in both specified collections.

Syntax

Code Block
INTERSECTION ( collection1 , collection2 )
Inputs
  • collection1, collection2 - Collections to be intersected. These collections must be of the same base type.

Return type

  • collection

Venn diagram

Image Removed

Examples

Suppose the following model. Entity Teacher has a multivalued relation with entity Child via the relation Teacher.teaches_Children.

Teacher instanceChild instanceChild.nameChild.hobbiesTeacher_1Child_1“Kim”“Reading”, “Dancing”Teacher_1Child_2“Rick”“Tennis”, “Dancing”Teacher_1Child_3“Bob”“Painting”, “Basketball”, “Reading”Teacher_2Child_1“Kim”“Reading”, “Dancing”Teacher_2Child_3“Bob”“Painting”, “Basketball”, “Reading”Teacher_2Child_4“Mary”“Football”ExpressionResultTypeINTERSECTION ( Teacher[Teacher_1].teaches_Children , Teacher[Teacher_2].teaches_Children )[ Child_1 , Child_3 ]Collection of Child instancesINTERSECTION ( Teacher[Teacher_1].teaches_Children.name , Teacher[Teacher_2].teaches_Children.name )[ "Kim" , "Bob" ]String (multivalued)INTERSECTION ( Child[Child_1].hobbies , Child[Child_3].hobbies )[ "Reading" ]String (multivalued)INTERSECTION ( Child[Child_2].hobbies , Child[Child_3].hobbies )[ ]String (multivalued)INTERSECTION( ?, [ 1, 2 ] )UNKNOWNInteger (multivalued)

Back to top

...

bgColorwhite

DIFFERENCE

This function returns a collection containing all the items from collection1 that are not present in collection2.

Syntax

Code Block
DIFFERENCE ( collection1 , collection2 )

...

  • collection1, collection2 - Collections to be compared. These collections must be of the same base type.

Return type

  • collection

Venn diagram

Image Removed

Examples

...

Back to top

...

bgColorwhite

SYMMETRIC_DIFFERENCE

This function determines the symmetric difference between two collections. It returns a collection with the elements of the provided collections which are in either one of the collections, but not in both.

Syntax

Code Block
SYMMETRIC_DIFFERENCE ( collection1 , collection2 )

...

  • collection1, collection2 - Collections to be compared. These collections must be of the same base type.

Return type

  • collection

Venn diagram

Image Removed

Examples

...

Back to top

...

bgColorwhite

A note on collections and duplicates

An expression resulting in a collection does not contain duplicates. Please be aware however, that intermediary results of a COLLECT statement can contain duplicates. You have to be aware of this when using the SIZE or UNPACK function, or when using TSL.

This is best illustrated with the following examples.

...

 TSL:

The ages present are: [[[ COLLECT Person.Age FROM ALL Person ]]].

...

Now an example with the UNPACK function. We leave out the first instance from the previous example.

...

UI Text Box
typenote

 Only the intermediary results of a COLLECT statement can contain duplicates. The functions UNIQUE, UNION, INTERSECTION, DIFFERENCE and SYMMETRIC_DIFFERENCE always return collections without duplicates.

Back to top