Page History
...
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.name | Person.gender | Person.age |
---|---|---|
“Kim” | “f” | 23 |
“Rick” | “m” | 35 |
“Bob” | “m” | 42 |
“John” | “m” | 19 |
“Mary” | “f” | 33 |
EXISTS Person
= TRUEEXISTS Person WHERE (Person.age < 18)
= FALSEEXISTS Person WHERE (Person.gender = “m” AND Person.age > 35)
= TRUE
UI Text Box | ||
---|---|---|
| ||
The return value of a boolean can be |
Section | |||||||
---|---|---|---|---|---|---|---|
|
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.name | Person.gender | Person.age |
---|---|---|
“Kim” | “f” | 23 |
“Rick” | “m” | 35 |
“Bob” | “m” | 42 |
“John” | “m” | 19 |
“Mary” | “f” | 33 |
EACH Person WHERE (Person.age < 18)
= FALSEEACH Person WHERE (Person.age > 18)
= TRUEEACH Person WHERE (Person.age < 20)
= FALSEEACH Person WHERE (Person.gender = “m” OR Person.age > 35)
= FALSEEACH 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 instance | Child instance | Child.name | Child.hobbies |
---|---|---|---|
Teacher_1 | Child_1 | “Kim” | “Reading”, “Dancing” |
Teacher_1 | Child_2 | “Rick” | “Tennis”, “Dancing” |
Teacher_1 | Child_3 | “Bob” | “Painting”, “Basketball”, “Reading” |
Teacher_2 | Child_1 | “Kim” | “Reading”, “Dancing” |
Teacher_2 | Child_3 | “Bob” | “Painting”, “Basketball”, “Reading” |
Teacher_2 | Child_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 | |||||||
---|---|---|---|---|---|---|---|
|
COLLECT FROM NAMED [WHERE]
...
Overview
Content Tools