Versions Compared

Key

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

...

This function determines whether an instance of a specified entity exists, optionally meeting certain criteria.

Syntax

Code Block
EXISTS instances [WHERE condition]
  • instancesinstances - Instances to search.
  • condition - Boolean boolean expression that represents the criterion the instance has to meet.

Return type

  • boolean

Examples

Suppose the following data model.

 

Person.namePerson.genderPerson.age
“Kim”“f”23
“Rick”“m”35
“Bob”“m”42
“John”“m”19
“Mary”“f”33

 

  • EXISTS Person returns = TRUE
  • EXISTS Person WHERE (Person.age < 18) returns = FALSE
  • EXISTS Person WHERE (Person.gender = “m” AND Person.age > 35) returns = TRUE
UI Text Box
typenote

The return value of a boolean can be TRUE, FALSE or UNKONWN UNKNOWN.

EACH

This function determines whether all instances of a specified entity meet a certain criteria

Syntax

Code Block
EACH instances WHERE condition
  • instancesinstances - A collection of instances to search.
  • condition - Boolean expression that represents the criterion the instance has to meet.

Return type

  • boolean

Examples

Suppose the following data model.

 

Person.namePerson.genderPerson.age
“Kim”“f”23
“Rick”“m”35
“Bob”“m”42
“John”“m”19
“Mary”“f”33

 

  • EACH Person WHERE (Person.age < 18) returns = FALSE
  • EACH Person WHERE (Person.age > 18) returns = TRUE
  • EACH Person WHERE (Person.age < 20) returns = FALSE
  • EACH Person WHERE (Person.gender = “m” OR Person.age > 35) returns = FALSE
  • EACH Person WHERE (Person.gender = “m” OR Person.age > 20) returns = TRUE

ALL

Use this function to create a collection of all instances of a specified entity.

Syntax

Code Block
 ALL entity
  • entity - Entity of which to collect all its instances.

Return type

  • collection of entity instances

Examples

Suppose the following data model. The Parent and Child entities both have Person as base entity.

 

Parent instanceChild instance
Parent_1Child_1
Parent_1Child_2
Parent_1Child_3
Parent_2Child_4

 

  • ALL Parent returns a collection of Parent = [ Parent_1 and , Parent_2 ]
  • ALL Child returns a collection of Child = [ Child_1 , Child_2 , Child_3 and , Child_44 ]
  • ALL Person returns a collection of Parent = [ Parent_1 , Parent_2 , Child_1 , Child_2 , Child_3 and , Child_44 ]

COLLECT FROM [WHERE]

Use this function to create a collection of entity or attribute instances (meeting certain criteria).

Syntax

Code Block
 COLLECT entity | attribute FROM collection [WHERE expression]
  • entity or attribute - Entity or attribute to collect.
  • collection - A collection of entity instances.
  • expression - Boolean expression that represents the criterion the instance has to meet.

Return type

  • collection of entity instances
  • collection of attribute values

Examples

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

 

Teacher instanceChild instanceChild.nameChild.hobbies
Teacher_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”

 

  • COLLECT Child.name FROM ALL Child results in a collection of the values “Kim”, “Rick”, “Bob” and “Mary”
  • COLLECT Child FROM Teacher[Teacher_2].teaches_Children results in a collection of the instances Child_1, Child_3 and Child_4
  • COLLECT Child.hobbies FROM Teacher[Teacher_1].teaches_Children results in a collection of the values “Reading”, “Dancing”, “Tennis”, “Painting” and “Basketball”
  • COLLECT Child.name FROM ALL Child WHERE (Child.hobbies = “Reading”) results in a collection of the values “Kim” and “Bob”
  • COLLECT Child.hobbies FROM ALL Child WHERE (Child.name = “Mary”) results in a collection of the value “Football”
Section
Column
width80%

 

Column

Top

 

COLLECT FROM NAMED [WHERE]

...