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]
  • instances - 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

 

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

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

Section
Column
width90%

 

Column

Top

EACH

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

Syntax

Code Block
EACH instances WHERE condition
  • instances - 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) = FALSE
  • EACH Person WHERE (Person.age > 18) = TRUE
  • EACH Person WHERE (Person.age < 20) = FALSE
  • EACH Person WHERE (Person.gender = “m” OR Person.age > 35) = FALSE
  • EACH Person WHERE (Person.gender = “m” OR Person.age > 20) = TRUE

...

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]

...