V1

A Visual Query Language for Property Graphs

V1: A Visual Query Language for Property Graphs

Copyright ยฉ 2017-2023 Lior Kogan (koganlior1 [at] gmail [dot] com)

The โ€œV1โ€ name is a trademark of Lior Kogan.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Commercial licenses and software tools are also available from Lior Kogan.

CC


This page contains the description and the specifications of the V1 language. This content is periodically released in arXiv.

V1 is named after the primary visual cortex in our brain, which is also known as visual area one (V1).

V1 is dedicated to my ancestors all the way back and their descendants all the way forth.

Feedback, questions, corrections, and suggestions are welcome.


Table of Contents

Introduction

The property graph is an increasingly popular data model. Pattern construction and pattern matching are important tasks when dealing with property graphs. Given a property graph schema ๐‘†, a property graph ๐บ conforming to ๐‘†, and a query pattern ๐‘ƒ conforming to ๐‘†, all expressed in language ๐ฟ = (๐ฟ๐‘†, ๐ฟ๐บ, ๐ฟ๐‘ƒ, ๐ฟ๐‘…), pattern matching is the process of finding, transforming, merging, and annotating subgraphs of ๐บ that match ๐‘ƒ. The syntaxes of sublanguages ๐ฟ๐‘†, ๐ฟ๐บ, ๐ฟ๐‘ƒ, and ๐ฟ๐‘… define what and how symbols can be combined to form well-formed schemas, graphs, patterns, and query results, respectively. A semantics of ๐ฟ๐‘ƒ is a mapping (๐‘†, ๐บ, ๐‘ƒ) โ†’ ๐‘…: which subgraphs of ๐บ match ๐‘ƒ and how to transform, merge, and annotate them. Expressive pattern languages support topological constraints, property value constraints, negations, quantifications, aggregations, and path semantics. Calculated properties may be defined for vertices, edges, and subgraphs, and constraints may be imposed on their evaluation result.

Many query posers are professionals (e.g., researchers, analysts, or investigators) who construct patterns as part of their daily work (e.g., investigative analytics). Such domain experts would like to construct patterns with minimal effort, minimal trial and error, and in a manner that is coherent with the way they think. The ability to express patterns in a way that is aligned with their mental processes is crucial to the flow of their work and to the quality of the insights they can draw. Many domain experts will not use textual property graph query languages (e.g., Gremlin, GSQL, Cypher, PGQL, G-CORE, and the proposed GQL) either because it can be too hard for someone with little or no programming or scripting skills, or because it requires them to spend too much time on the technicalities and distracts them from their line of inquiry. As a result, they are forced to use only a predefined set of query templates or work in concert with technical experts. Both solutions are far from satisfying.

Since the pattern perception capabilities of the human visual cortex are remarkable, it is a matter of course that query patterns were to be expressed visually. Indeed, five of the abovementioned languages use โ€˜ASCII art syntaxโ€™ for expressing topological constraints. Needless to say, this type of โ€˜visualizationโ€™ is quite limited. While the use of ASCII art declined during the 1990s in favor of graphical images, query languages began to adopt ASCII art only recently. Visual (graphical, diagrammatic) query languages have the potential to be much more โ€˜user-friendlyโ€™ than their textual counterparts in the sense that patterns may be constructed and understood much more quickly and with much less mental effort. Given a schema, interactive tools can allow query posers to construct valid patterns with minimal typing. A long-standing challenge is to design a visual query language that is generic, has rich expressive power, and is highly receptive and productive. V1 attempts to answer this challenge.

V1 is a declarative visual pattern query language for schema-based property graphs. V1 supports property graphs with mixed (both directed and undirected) edges, multivalued and composite properties, and null property values. V1 supports temporal data types, operators, and functions and can be extended to support additional data types, operators, and functions (one spatiotemporal model is presented). V1 is generic, concise, has rich expressive power, and is highly receptive and productive.

The Property Graph Data Model

The term property graph refers to both a mathematical structure and a data model; both are described below.

Mathematical Structure:

A graph is an ordered quintet ๐บ = (๐‘‰, ๐ธ, ๐ด, ฯˆโ‚‘, ฯˆโ‚) consisting of three pairwise disjoint sets and two functions. ๐‘‰ is a nonempty set whose elements are called vertices (nodes, dots, points), ๐ธ is a set whose elements are called undirected edges (undirected links, undirected lines), ๐ด is a set whose elements are called directed edges (directed links, directed lines, arcs, arrows), ฯˆโ‚‘: E โ†’ { {u,v}: u,v โˆˆ V } is a total function mapping each undirected edge to an unordered pair of vertices, and ฯˆโ‚: A โ†’ { (u,v): u,v โˆˆ V } is a total function mapping each directed edge to an ordered pair of vertices. An undirected graph is a graph in which ๐ด โ‰” โˆ…. A directed graph (digraph, oriented graph) is a graph in which ๐ธ โ‰” โˆ…. A mixed graph is a graph where both directed and undirected edges may exist.

Given undirected edge ๐‘’ such that ฯˆโ‚‘(๐‘’) = {๐‘ข,๐‘ฃ}, we say that ๐‘’ is an edge between ๐‘ข and ๐‘ฃ, ๐‘’ connects (joins) ๐‘ข and ๐‘ฃ, and ๐‘ข and ๐‘ฃ are adjacent. Likewise, given directed edge ๐‘Ž such that ฯˆโ‚(๐‘Ž) = (๐‘ข,๐‘ฃ), we say that ๐‘Ž is an edge from ๐‘ข to ๐‘ฃ, ๐‘Ž connects (joins) ๐‘ข to ๐‘ฃ, ๐‘ฃ is adjacent from (out-adjacent to) ๐‘ข, ๐‘ข is adjacent to (in-adjacent to) ๐‘ฃ, ๐‘ข is the tail (source vertex, initial vertex) of ๐‘Ž, and ๐‘ฃ is the head (target vertex, terminal vertex) of ๐‘Ž. A loop is a directed or undirected edge connecting a vertex with itself. Multiple edges (parallel edges) are two or more undirected edges connecting the same unordered pair of vertices or directed edges connecting the same ordered pair of vertices. A simple graph is a graph in which multiple edges and loops are not allowed. A pseudograph is a graph in which multiple edges and loops are allowed.

An attributed graph is a generic term referring to graphs in which an attribute (single-attributed graph) or a set, a bag, or a list of attributes (multi-attributed graph) may be associated with each vertex (vertex-attributed graph), edge (edge-attributed graph), or the graph itself. An attribute may be a nominal value, an ordinal value, a key-value pair, or other annotation. (The term attributes is sometimes used to refer only to key-value pairs, while labels is used to refer to nominal attributes).

A property graph (PG, labeled property graph, LPG) is a vertex-multi-attributed edge-multi-attributed directed pseudograph in which:

A mixed property graph is mixed instead of directed.

Data Model:

Data is a representation of information. A data element (datum) is an atomic unit of data, hence, an atomic unit of representation of information. A data model specifies the semantics and defines the structure of data elements and the relations between data elements. A data model consists of:

The [mixed] property graph data model comprises the following concepts:

The property graph data model can hence represent heterogeneous graphs - graphs that may contain multiple types of entities (multi-modal graph), of relationships (multi-relational graph), and of actions. In addition, each entity, relationship, or action may have multiple features (multifeatured graph).

The property graph data model is a metamodel, as it does not specify types of entities, relationships, and actions, nor does it specify sets of features. It is domain-agnostic. Instead, domain-specific concepts may be specified and enforced using a property graph schema (see next section).

The [mixed] property graph data model comprises the following structure:

๐‘›-ary relationships, where ๐‘› > 2, are not supported. However, this poses no expressivity limitation since any ๐‘›-ary relationship, ๐‘› > 2, can be reframed as an entity and ๐‘› binary relationships. Consider, for example, a ternary relationship, where Person ๐ด sells Horse ๐ป to Person ๐ต. Instead, one can reframe this data as a Sale entity ๐‘†, a seller relationship from ๐‘† to ๐ด, a buyer relationship from ๐‘† to ๐ต, and an asset relationship from ๐‘† to ๐ป.

The term property graph was introduced by Rodriguez and Neubauer, though other terms were used to describe similar data models. Tsai and Fuโ€™s attributed relational graph is a directed multigraph in which both nodes and edges have labels, and each label defines a set of numerical or logical attributes. Shao et al. used the term Heterogeneous graph for the same construct. Gallagher used the term data graph to refer to graphs in which vertices and/or edges may be typed and/or attributed. Singh et al. used the term M*3 (multi-modal, multi-relational, multifeatured) network to refer to graphs with multiple entity-types, multiple relationship-types, and multiple descriptive features for nodes and edges. Krause et al. used the term typed graph to refer to graphs with typed nodes, typed edges, and typed node properties.

Various extensions were proposed, including:

The Property Graph Schema

A schema is a model for describing the structure of information in a certain domain using a certain data model. A property graph schema defines the entity-types, the relationship-types, and the properties of thereof.

The property graph data model is schema-optional. Each property graph may be:

It is much easier to define patterns when the information is presented consistently. For example, to match patterns such as Any person who owns a white horse, one would first:

Though proposed property graph and property graph schema definitions have much in common (see Angles, Wu, Hartig and Hidders, and Angles et al.), to date, there is neither a de jure nor a de facto standard definition (and hence, no standard property graph schema definition language).

The following property graph schema model is assumed in this paper:

A property graph schema is defined by:

A predefined property-less entity-type Null serves two purposes:

Property graph schema definitions may vary in many aspects, including:

V1 can be utilized with most definitions with minimal changes.

Patterns and Pattern Languages

A pattern defines a set of topological and property value constraints on property graphs. Each property (sub)graph either matches the pattern or not. For some patterns, a given (sub)graph may match a pattern in more than one way.

When a pattern is described in a natural language, it may be ambiguous or inaccurate. Nevertheless, all the patterns below are described in English. After all, to allow a reader to gain an intuitive understanding of a formal language, one has to use a natural language.

Here are two examples:

The terms entity and relationship denote both pattern elements and graph elements. When the context may be ambiguous, we use the terms pattern-entity and pattern-relationship to refer to pattern elements and the terms graph-entity and graph-relationship to refer to graph elements.

Given a property graph schema ๐‘†, a property graph ๐บ conforming to ๐‘†, and a query pattern ๐‘ƒ conforming to ๐‘†, all expressed in language ๐ฟ = (๐ฟ๐‘†, ๐ฟ๐บ, ๐ฟ๐‘ƒ, ๐ฟ๐‘…), pattern matching is the process of finding, transforming, merging, and annotating subgraphs of ๐บ that match ๐‘ƒ. The syntaxes of sublanguages ๐ฟ๐‘†, ๐ฟ๐บ, ๐ฟ๐‘ƒ, and ๐ฟ๐‘… define what and how symbols may be combined to form well-formed schemas, graphs, patterns, and query results, respectively. A semantics of ๐ฟP is a mapping (๐‘†, ๐บ, ๐‘ƒ) โ†’ ๐‘…: which subgraphs of ๐บ match ๐‘ƒ and how to transform, merge, and annotate them.

Any valid subgraph that matches the pattern is called an assignment. We use assignment to ๐‘‹ where ๐‘‹ is a pattern-entity, a pattern-relationship, or a set of thereof, to denote the graph-entity, the graph-relationship, or the set of thereof that matches ๐‘‹ as part of an assignment.

In the patterns given below, unless otherwise stated, each reported assignment should include the graph-entity assigned to each mentioned pattern-entity and the graph-relationship assigned to each mentioned pattern-relationship. Hence, any reported assignment to P1 should be composed of:

Consider the following alternative patterns:

A query may be:

Implementations may support one or more of the above.

V1 introduces the concept of calculated properties - non-inherent properties of graph-entities, graph-relationships, and subgraphs, defined as part of a pattern. Each calculated propertyโ€™s evaluation result can be part of the reported query results, extending V1 capabilities beyond โ€˜simpleโ€™ pattern matching. For example, The average number of horse ownerships per person - a calculated property of the set of all graph-entities of type Person can be defined as part of a pattern. See Q356).

Pattern languages differ in many aspects, including:

There are always tradeoffs, especially between receptivity and productivity and expressive power. Quoting Perlisโ€™ 54th and 55th epigrams of programming: โ€œBeware of the Turing tar-pit in which everything is possible but nothing of interest is easy.โ€ and โ€œA LISP programmer knows the value of everything, but the cost of nothing.โ€ Perlisโ€™ 93rd and 26th epigrams are also worth quoting here: โ€œWhen someone says, โ€˜I want a programming language in which I need only say what I wish done,โ€™ give him a lollipop.โ€ and โ€œThere will always be things we wish to say in our programs that in all known languages can only be said poorly.โ€ Though these epigrams refer to programming languages, they are equally valid for property graph query languages.

A Song of Ice and Fire

The following scenario, loosely based on George R. R. Martinโ€™s A Song of Ice and Fire will serve us to demonstrate the languageโ€™s expressive power.

The subjects of Sarnor, Omber, and the other kingdoms of the known world love their horses. There is one thing they adore even more - that is their dragons. They own dragons of ice and fire. Like all well-behaved dragons, their dragons love to play. Dragons always play in couples. When playing, dragons often get furious, fire at each other (fire breath), and freeze one another (cold breath). Dragons usually freeze one another for periods of several minutes. However, on occasion, when they are furious, they can freeze one another for periods of several hours. The subjects enjoy watching their dragons play. Fascinated by these magnificent creatures, they have composed myriads of scrolls detailing each fire breath and cold breath over the last thousand years. The kings of Sarnor and Omber regularly pose queries about their history. More than often, it takes the royal historians and analysts several days to come up with answers, during which the kings tend to get pretty impatient. Lately, the high king of Sarnor posed a very complex query. After waiting for results for more than two moons, he ordered the chief analyst to be executed. He then summoned his chief mechanics and ordered them to develop an apparatus that he could use to pose queries and get results quickly.

The engineers started by collecting all queries posed by their master over the last few years. Then they constructed a property graph schema over which these queries can be expressed.

The schema was composed of the following entity-types (and their properties):

the following directional relationship-types (and their properties):

and of the following bidirectional relationship-type (and its properties):

Personโ€™s name is a composite property. The date, datetime, dateframe, and datetimeframe data types are defined in Data Types, Operators, and Functions.

The engineers then represented the whole known history using a property graph conforming to this schema.

V1 Basics

The following sections describe the syntax and the semantics of the V1 language. We start with the basics, adding more language elements as we go along.

Note: V1 has two equivalent syntaxes for expressing patterns: A visual syntax - described below, and a textual syntax (JSON-based) - summarized here. There is a bijective mapping between patterns expressed in these two syntaxes. Sample textual patterns are available here. A V1 schema for A Song of Ice and Fire is available here.

V1

V1

Patterns are generally read from left to right. Each pattern starts with a small black diamond, denoting the pattern start. The most straightforward patterns are structured as a sequence of rectangles, where consecutive rectangles are connected with an arrow or a line.

Yellow, blue, and red rectangles represent concrete, typed and untyped entities, respectively. The terms concrete entity, typed entity, and untyped entity refer to pattern entities only (and not to graph entities).

A yellow rectangle represents a concrete entity: a specific person, a specific horse, etc. A concrete entity has a single assignment - a specific graph-entity. The text inside the rectangle denotes the entity-type and the value of a visualization expression defined for this entity-type. For example, the visualization-expression for the Person entity-type may be: name.first โˆฅ โ€˜ โ€˜ โˆฅ name.last and its value, for a specific graph-entity, would be โ€˜Brandon Starkโ€™.

A blue rectangle represents a typed entity. The text inside the rectangle denotes an entity-type. Only graph-entities of this type may be assigned to the pattern-entity.

A red rectangle represents an untyped entity. Graph-entities of different types may be assigned to an untyped entity. An optional text inside the rectangle denotes an entity-type constraint (See Untyped Entities).

Two consecutive rectangles can be connected with:

The terms typed relationship and untyped relationship refer only to pattern relationships. The term path may refer to both graph-path and pattern-path.

Each black arrow/line has a label on top. The label denotes a relationship-type. For arrows - the label is aligned to the arrowโ€™s origin. For lines - the label is centered. Only graph-relationships of this type can match the pattern-relationship.

A pattern matching engine would look in the property graph for assignments for every blue rectangle, red rectangle, black arrow, and black line. Graph entities are assigned to pattern entities. Graph relationships are assigned to pattern relationships. An assignment to the pattern is a set of graph-entities and graph-relationships that matches the whole pattern.

The relationship-type between any two entities must be valid with respect to the schema.

Q1: Any dragon owned by Brandon Stark (two versions)

V1

V1

Q2: Any dragon C that at least once had been frozen by a dragon owned by Brandon Stark

V1

Q184: Any dragon C that at least once froze a dragon owned by Brandon Stark or was frozen by a dragon owned by Brandon Stark

V1

Both directions of the freezes relationship are acceptable. Therefore - a line (instead of an arrow) is used in the pattern.

Expressions and Expression Constraints

V1

A green rectangle represents an expression. The rectangle contains:

expr is an entityโ€™s expression, a relationshipโ€™s expression, or a Cartesian productโ€™s expression, or a global expression.

Any expression-tag of an expression that is not a property name, a subproperty name, or a constant is called a calculated property.

An expression is

An interval can be explicitly constructed using the following syntaxes:

A set is an unordered collection of zero or more non-null values (called elements) of the same data type in which each element may occur only once.

A set can be explicitly constructed using the following syntax:

A bag (multiset) is an unordered collection of zero or more non-null values (called elements) of the same data type in which elements may occur more than once.

A bag can be explicitly constructed using the following syntax:

A list is an ordered collection of values (called elements) of the same data type in which elements may occur more than once.

A list can be explicitly constructed using the following syntax:

Expressions must match the data types defined for each operator and function.

A constraint filters assignments; an assignment is valid only if the result of the expressionโ€™s evaluation satisfies the constraint.

A constraint cannot be defined for a concrete entityโ€™s expression.

For untyped entities, expressions can be composed only of properties common to all valid entity-types. Valid entity-types for an untyped entity are defined implicitly (according to the types of the pattern-entities and pattern-relationships which are connected to the untyped entity) or explicitly (using entity-type constraints - see later) (see Q291).

A subproperty of a composite property is denoted as <_property name_="">.<_subproperty name_=""> (e.g., _name.first_, _tf.since_).

Q3: Any person whose first name is Brandon who owns a dragon (version 1)

V1

{1} is a property of each unique assignment to B.

Q190: Any person who became a dragon owner at 1011 or later (two versions)

V1

{1} is a property of each unique assignment to the owns relationship.

V1

year is a function (see next section).

All V1 constraint operators, except is null and not null, are first evaluated using Kleeneโ€™s three-valued logic (3VL) to true, false, or unknown, and then mapped to a two-valued logic: the constraint is either satisfied or not satisfied.

Each constraint operator, except is null and not null, can be either blue or red.

V1

The following constraint operators can be only blue:

V1

Data Types, Operators, and Functions

All V1โ€™s operators and functions must be well-defined when one or more of the operands or parameters are null or evaluated to null. Null-valued [sub]properties are interpreted as applicable missing or no information (e.g., 1 + null = null; max(5, null) = null).

Since V1 is schema-based, there is no need to define the behavior of each operator for any combination of operand types (and similarly, for each function for any combination of parameter types). When types do not match the definition (e.g., 5 > โ€˜abcโ€™, round(โ€˜abcโ€™)) โ€“ the query is invalid. Type mismatch should be detected during query analysis. In addition, interactive pattern-building tools should disallow the construction of such queries.

One design goal of V1 is to make it applicable to many property graph database management systems. Implementations may support different data types, operators, and functions than those presented here.

To present V1, we use the following data types, operators, and functions:

Built-in basic data types:

Type Notes
int Integer
float Floating-point
date Date. For simplicity, we will not consider time zones here.
datetime Date and time. For simplicity, we will not consider time zones here.
duration Can be negative
string Unicode string

Built-in composite data types:

Type Notes
dateframe {since: date, till: date}
datetimeframe {since: datetime, till: datetime}

Literals:

Type Examples
integer 12, -3
float 3., 3.12, -1.78e-6, NaN, -INF, +INF
string โ€โ€, โ€œabcโ€, โ€˜abcโ€™

We will use St, Bt, and Lt, to denote a set, a bag, and a list of elements of type ๐‘ก, respectfully, and It to denote an interval of ordinal type ๐‘ก.

Operators:

Operator (op) Operands and result type (result may be null as well)
+, - (unary) op int โ†’ int
op float โ†’ float
If the operand is NaN โ€“ the result is NaN. Otherwise, If it is null โ€“ the result is null
+, - (binary) int op int โ†’ int
float op float โ†’ float
duration op duration โ†’ duration
duration + date โ†’ date
date op duration โ†’ date
duration + datetime โ†’ datetime
datetime op duration โ†’ datetime
If one or both operands are NaN โ€“ the result is NaN. Otherwise, if one or both operands are null โ€“ the result is null
* int * int โ†’ int
float * float โ†’ float
float * duration โ†’ duration
duration * float โ†’ duration
If one or both operands are null - the result is null
/ int / int โ†’ int (truncated towards zero)
float / float โ†’ float
duration / float โ†’ duration
If one or both operands are null - the result is null
% (modulo) int % int โ†’ int (remainder has the same sign as the dividend)
If one or both operands are null - the result is null
โˆช, โˆฉ, -, โ–ณ
(union, intersection, difference, symmetric difference)
St op St โ†’ St (๐‘ก is any type)
Bt op Bt โ†’ Bt (๐‘ก is any type) (see Q377)
If one or both operands are null - the result is null
โˆฅ (concatenation) string โˆฅ string โ†’ string. ๐‘  โˆฅ null = null โˆฅ ๐‘  = null
Lt โˆฅ Lt โ†’ Lt (๐‘ก is any type). null โˆฅ ๐ฟ = ๐ฟ โˆฅ null = null
๐‘ก โˆฅ Lt โ†’ Lt (๐‘ก is any type). null โˆฅ ๐ฟ = (null, โ€ฆ). ๐ฟ. ๐‘ก โˆฅ null = null
Lt โˆฅ ๐‘ก โ†’ Lt (๐‘ก is any type). ๐ฟ โˆฅ null = (โ€ฆ, null). null โˆฅ ๐‘ก = null

Constraint Operators:

Operator (op) Operands type (result is false / true / unknown)
is null, not null (unary) any_type op
An empty set / bag / list is not a null value.
=, โ‰  both operands of the same type (any type)
unknown if at least one operand is null
Exceptions for float:
(NaN = null) = false; (NaN โ‰  null) = true
<, >, โ‰ค, โ‰ฅ both operands of the same ordinal type:
int / float / date / datetime / duration / string / other ordinal
unknown if at least one operand is null.
Exceptions for string:
(โ€œโ€ โ‰ค null) = (null โ‰ฅ โ€œโ€) = true
(โ€œโ€ > null) = (null < โ€œโ€) = false
(โ€œโ€ > null) = (null < โ€œโ€) = false
Exceptions for float:
(null โ‰ค NaN) = (null โ‰ฅ NaN) = (null < NaN) = (null > NaN) = false
(NaN โ‰ค null) = (NaN โ‰ฅ null) = (NaN < null) = (NaN > null) = false
Exceptions for bounded types with no NaN value:
(lb โ‰ค null) = (null โ‰ฅ lb) = (ub โ‰ฅ null) = (null โ‰ค ub) = true
(ub < null) = (null > ub) = (lb > null) = (null < lb) = false
where lb is the lower bound (e.g., INT_MIN for integer) and hb is the upper bound (e.g., INT_MAX for integer)
โˆˆ, โˆ‰ ([not] in) left operand: any type ๐‘ก. right operand: St / Bt / Lt
unknown if at least one operand is null. Exceptions:
(null โˆˆ {}/[]/()) = false; (null โˆ‰ {}/[]/()) = true

left operand: any ordinal type ๐‘ก. right operand : It
unknown if at least one operand is null. Exceptions:
(null โˆˆ empty interval) = false; (null โˆ‰ empty interval) = true
๐‘ก is int: (null โˆˆ [INT_MIN, INT_MAX]) = true; (null โˆ‰ [INT_MIN, INT_MAX]) = false
โˆ‹, โˆŒ ([not] contains) right operand: any type ๐‘ก. left operand: St / Bt / Lt
unknown if at least one operand is null. Exceptions:
({}/[]/() โˆ‹ null) = false; ({}/[]/() โˆŒ null) = true

right operand: any ordinal type ๐‘ก. left operand : It
unknown if at least one operand is null. Exceptions:
(empty interval โˆ‹ null) = false; (empty interval โˆŒ null) = true
๐‘ก is int: ([INT_MIN, INT_MAX] โˆ‹ null) = true; ([INT_MIN, INT_MAX] โˆŒ null) = false
โŠ†, โŠˆ ([not] sub of)
โŠ‚, โŠ„ ([not] proper sub of)
both operands: string
unknown if at least one operand is null. Exceptions:
(null โŠ‚ โ€œโ€) = false; (null โŠ„ โ€œโ€) = true
(โ€œโ€ โŠ† null) = true; (โ€œโ€ โŠˆ null) = false

both operands of the same type: St / Bt / Lt (t is any type)
unknown if at least one operand is null. Exceptions:
(null โŠ‚ {}/[]/()) = false; (null โŠ„ {}/[]/()) = true
({}/[]/() โŠ† null) = true; ({}/[]/() โŠˆ null) = false

๐‘ก is ordinal, and both operands of the same type: It
unknown if at least one operand is null. Exceptions:
(null โŠ‚ empty interval) = false; (null โŠ„ empty interval) = true
(empty interval โŠ† null) = true; (empty interval โŠˆ null) = false
๐‘ก is int: (null โŠ‚ [INT_MIN, INT_MAX]) = true; (null โŠ„ [INT_MIN, INT_MAX]) = false
โŠ‡, โŠ‰ ([not] super of)
โŠƒ, โŠ… ([not] proper super of)
both operands: string
unknown if at least one operand is null. Exceptions:
(null โŠ‡ โ€œโ€) = true; (null โŠ‰ โ€œโ€) = false
(โ€œโ€ โŠƒ null) = false; (โ€œโ€ โŠ… null) = true

both operands of the same type: St / Bt / Lt (t is any type)
unknown if at least one operand is null. Exceptions:
(null โŠ‡ {}/[]/()) = true; (null โŠ‰ {}/[]/()) = false
({}/[]/() โŠƒ null) = false; ({}/[]/() โŠ… null) = true

๐‘ก is ordinal, and both operands of the same type: It
unknown if at least one operand is null. Exceptions:
(null โŠ‡ empty interval) = true; (null โŠ‰ empty interval) = false
(empty interval โŠƒ null) = false; (empty interval โŠ… null) = true
๐‘ก is int: ([INT_MIN, INT_MAX] โŠƒ null) = true; ([INT_MIN, INT_MAX] โŠ… null) = false
โŠณ, โ‹ซ ([not] starts with) both operands: string
unknown if at least one operand is null. Exceptions:
(null โŠณ โ€œโ€) = true; (null โ‹ซ โ€œโ€) = false

left operand: Lt. right operand: ๐‘ก (๐‘ก is any type)
unknown if at least one operand is null. Exceptions:
(() โŠณ null) = false; (() โ‹ซ null) = true

left operand: Lt. right operand: Lt (๐‘ก is any type)
unknown if at least one operand is null. Exceptions:
(null โŠณ ()) = true; (null โ‹ซ ()) = false
โŠฒ, โ‹ช ([not] ends with) both operands: string
unknown if at least one operand is null. Exceptions:
(null โŠฒ โ€œโ€) = true; (null โ‹ช โ€œโ€) = false

left operand: Lt. right operand: ๐‘ก (๐‘ก is any type)
unknown if at least one operand is null. Exceptions:
(() โŠฒ null) = false; (() โ‹ช null) = true

left operand: Lt. right operand: Lt (๐‘ก is any type)
unknown if at least one operand is null. exceptions:
(null โŠฒ ()) = true; (null โ‹ช ()) = false
โ‰, โ‰ญ ([not] match) both operands: string (right operand is a regex string)
unknown if at least one operand is null. Exceptions:
(null โ‰ โ€œโ€) = true; (null โ‰ญ โ€œโ€) = false

Implicit Type Coercion

From type (t1) To type (t2) Examples
int float 5 + 3. โ†’ 8.
date datetime date(โ€œ2018-04-05โ€) = datetime(โ€œ2018-04-05T00:00:00โ€) โ†’ true
dateframe datetimeframe dateframe(โ€œ2018-04-05โ€, โ€œ2018-04-08โ€) = datetimeframe(โ€œ2018-04-05T00:00:00โ€, โ€œ2018-04-08T23:59:59.999999999โ€)
dateframe interval(date) df.duration, where df is a dateframe property
datetimeframe interval(datetime) tf.duration, where tf is a datetimeframe property
interval(date) dateframe (date(โ€œ2018-04-05โ€) .. date(โ€œ2018-05-05โ€)).since โ†’ date(โ€œ2018-04-05โ€)
interval(datetime) datetimefrmae (date(โ€œ2018-04-05โ€) .. datetime(โ€œ2018-05-05T00:00โ€)).since โ†’ datetime(โ€œ2018-04-05T00:00โ€)

Also, based on any of these coercion rules:

From type To type Examples
{} (empty set) set(t2) of any type t2 {} โˆช {5} โ†’ {5}
[] (empty bag) bag(t2) of any type t2 [] โˆช [5] โ†’ [5] (see Q349)
() (empty list) list(t2) of any type t2 () โˆฅ (5,) โ†’ (5,)
set(t1) set(t2) {3, 5, 8} โˆช {3., 8.) โ†’ {3., 5., 8.}
bag(t1) bag(t2) [3, 5, 8] โˆช [3., 8.] โ†’ [3., 3., 5., 8., 8.]
list(t1) list(t2) (3, 5, 8) โˆฅ (3., 8.) โ†’ (3., 5., 8., 3., 8.)
interval(t1) interval(t2) (3 .. 8) = (3. .. 8.) โ†’ true (3 .. 8) โŠƒ (3. .. 5.) โ†’ true
{t1, t2, โ€ฆ} set(t2) * {3, 5.) โ†’ {3., 5.)
[t1, t2, โ€ฆ] bag(t2) * [3, 5.] โ†’ [3., 5.]
(t1, t2, โ€ฆ) list(t2) * (3, 5.) โ†’ (3., 5.)
t1 .. t2 interval(t2) * [3 .. 5.) โ†’ [3. .. 5.)

* where there is implicit type coercion from t1 to t2

Functions

Functions over float expressions:

Function Notes
trunc(float) โ†’ int truncates toward zero
round(float) โ†’ int rounds to the nearest integer (see G13)
mRound(float, int) โ†’ int rounds to the nearest multiple of a given integer (see G9, G10)
seconds(float) โ†’ duration (e.g., seconds(6) is a duration of 6 seconds)
minutes(float) โ†’ duration See G10
hours(float) โ†’ duration ย 
days(float) โ†’ duration See Q216, Q289
weeks(float) โ†’ duration One week = 7 days
months(float) โ†’ duration One month = 30.4367 days (see Q110)
years(float) โ†’ duration One year = 365.24 days (see Q317)

Functions over string expressions:

Function Notes
length(string) โ†’ int See Q255
toLower(string) โ†’ string See Q308
date(string) โ†’ date String format: YYYY-MM-DD (e.g., โ€œ2018-04-23โ€)
In visual syntax the, function name is omitted, and the string is formatted according to the regional settings.
datetime(string) โ†’ datetime String format: YYYY-MM-DDTHH:MM[:SS[.sss]]
(e.g., โ€œ2018-04-23T12:34:00โ€)
In visual syntax, the function name is omitted, and the string is formatted according to the regional settings.
duration(string) โ†’ duration String format adapted from Cypher: P[nY][nM][nW][nD][T[nH][nM][nS]]
(e.g., โ€œP1Y2M10DT12H45M30.25Sโ€)
Y: years, M: months, W: weeks, D: days, H: hours, M: minutes, S: seconds
In visual syntax, the function name is omitted, and the string is formatted.

Functions over datetime expressions:

Function Notes
date(datetime) โ†’ date See Q158
year(datetime) โ†’ int See Q185
month(datetime) โ†’ int The month of the year (1-12)
day(datetime) โ†’ int The day of the month (1-31)
hour(datetime) โ†’ int 0-23 (see G4)
minute(datetime) โ†’ int 0-59
sec(datetime) โ†’ int 0-59
yearsSinceEpoch(datetime) โ†’ float ย 
monthsSinceEpoch(datetime) โ†’ float ย 
weeksSinceEpoch(datetime) โ†’ float ย 
daysSinceEpoch(datetime) โ†’ float ย 
hoursSinceEpoch(datetime) โ†’ float ย 
minsSinceEpoch(datetime) โ†’ float ย 
span(datetime, datetime) โ†’ duration Positive difference (see Q374)

Functions over date expressions:

Function Notes
year(date) โ†’ int ย 
month(date) โ†’ int The month of the year (1-12)
day(date) โ†’ int The day of the month (1-31)
yearsSinceEpoch(date) โ†’ float ย 
monthsSinceEpoch(date) โ†’ float ย 
weeksSinceEpoch(date) โ†’ float ย 
daysSinceEpoch(date) โ†’ float ย 

Functions over dateframe expressions:

Function Notes
duration(dateframe) โ†’ duration ย 
overlap(dateframe, dateframe) โ†’ duration Always non-negative (see Q267v2)

Functions over datetimeframe expressions:

Function Notes
duration(datetimeframe) โ†’ duration See Q110
overlap(datetimeframe, datetimeframe) โ†’ duration Always non-negative

Functions over duration expressions:

Function Notes
years(duration) โ†’ float One year = 365.24 days
months(duration) โ†’ float One month = 30.4367 days
weeks(duration) โ†’ float One week = 7 days
days(duration) โ†’ float See Q328
hours(duration) โ†’ float ย 
minutes(duration) โ†’ float ย 
seconds(duration) โ†’ float ย 

Functions over set expressions:

Function Notes
count(St) โ†’ int number of elements
bag(St) โ†’ Bt set to bag
list(St) โ†’ Lt set to list
el(St) โ‡‰ ๐‘ก (see Multivalued Functions and Expressions)
subset(St) โ‡‰ St (see Multivalued Functions and Expressions)
min(St) โ†’ ๐‘ก
max(St) โ†’ ๐‘ก
๐‘ก is an ordinal type
null when St is null or when it is empty
avg(St) โ†’ ๐‘ก or float ๐‘ก is an ordinal type
if ๐‘ก is int - the result is float
null when St is null or when it is empty
sum(St) โ†’ ๐‘ก ๐‘ก is int / float / duration (not date / time / datetime)
null when St is null; zero when it is empty
min(St, n: int) โ†’ St
max(St, n: int) โ†’ St
Set of (up to) max(0, ๐‘›) smallest/largest values
๐‘ก is an ordinal type
null when St is null, {} when it is empty
overlap(Sdateframe) โ†’ duration
overlap(Sdatetimeframe) โ†’ duration
The duration of the overlap between all members of ๐‘†
Always non-negative (see Q371)
union(SSt) โ†’ St
union(SBt) โ†’ Bt
The union of all members of a set of sets/bags (๐‘ก is any type)
intersection(SSt) โ†’ St
intersection(SBt) โ†’ Bt
The intersection of all members of a set of sets/bags (๐‘ก is any type)

Functions over bag expressions:

Function Notes
count(Bt) โ†’ int number of elements
distinct(Bt) โ†’ int number of distinct elements
multiplicity(Bt, ๐‘ก) โ†’ int number of times ๐‘ก occurs in Bt
set(Bt) โ†’ St bag to set
list(Bt) โ†’ Lt bag to list
el(Bt) โ‡‰ ๐‘ก (see Multivalued Functions and Expressions)
subbag(Bt) โ‡‰ Bt (see Multivalued Functions and Expressions)
min(Bt) โ†’ ๐‘ก
max(Bt) โ†’ ๐‘ก
๐‘ก is an ordinal type
null when Bt is null or when it is empty
avg(Bt) โ†’ ๐‘ก or float ๐‘ก is an ordinal type
if ๐‘ก is int - the result is float
null when Bt is null or when it is empty
sum(Bt) โ†’ ๐‘ก ๐‘ก is int / float / duration (not date / time / datetime)
null when Bt is null; zero when it is empty
min(Bt, n: int) โ†’ Bt
max(Bt, n: int) โ†’ Bt
Bag of (up to) max(0, ๐‘›) smallest/largest values (see Q377)
๐‘ก is an ordinal type
null when Bt is null, [] when it is empty
overlap(Bdateframe) โ†’ duration
overlap(Bdatetimeframe) โ†’ duration
The duration of the overlap between all members of ๐ต
Always non-negative
union(BSt) โ†’ St
union(BBt) โ†’ Bt
The union of all members of a bag of sets/bags (๐‘ก is any type)
intersection(BSt) โ†’ St
intersection(BBt) โ†’ Bt
The intersection of all members of a bag of sets/bags (๐‘ก is any type)

Functions over list expressions (๐‘ก):

Function Notes
count(Lt) โ†’ int number of elements
distinct(Lt) โ†’ int number of distinct non-null elements
multiplicity(Lt, ๐‘ก) โ†’ int number of times ๐‘ก occurs in Lt
at(Lt, n: int) โ†’ t ๐‘›โ€™th element (1-based)
null if ๐‘› is out of range
set(Lt) โ†’ St list to set
bag(Lt) โ†’ Bt list to bag
min(Lt) โ†’ ๐‘ก
max(Lt) โ†’ ๐‘ก
๐‘ก is an ordinal type
null values are ignored
null when Lt is null or when it contains no non-null elements
avg(Lt) โ†’ ๐‘ก or float ๐‘ก is an ordinal type
if ๐‘ก is int - the result is float
null values are ignored
null when Lt is null or when it contains no non-null elements
sum(Lt) โ†’ ๐‘ก ๐‘ก is int / float / duration (not date / time / datetime)
null values are ignored
zero when Lt is null or when it contains no non-null elements
min(Lt, n: int) โ†’ Lt
max(Lt, n: int) โ†’ Lt
List of (up to) max(0, ๐‘›) smallest/largest values
๐‘ก is an ordinal type
null values are ignored
null when Lt is null, () when it contains no non-null elements
sort(Lt) โ†’ Lt Sorted list
๐‘ก is an ordinal type
invsort(Lt) โ†’ Lt Inverse-sorted list
๐‘ก is an ordinal type

Functions over interval expressions:

Function Notes
lb(It) โ†’ ๐‘ก Lower bound
null when It is null
up(It) โ†’ ๐‘ก Upper bound
null when It is null
set(It) โ†’ St Interval to set
๐‘ก is discrete (int, datetime, or another ordinal type)
null when It is null
bag(It) โ†’ Bt Interval to bag
๐‘ก is discrete (int, datetime, or another ordinal type)
null when It is null
list(It) โ†’ Lt Interval to list
๐‘ก is discrete (int, datetime, or another ordinal type)
null when It is null

Other functions:

Function Notes
now โ†’ datetime See Q8v2, G11
today โ†’ date See Q328
date(year, month, day) โ†’ date Construct date using three integers (see Q353)
null when at least one value is null
min(๐‘ก, ๐‘ก, โ€ฆ) โ†’ ๐‘ก
max(๐‘ก, ๐‘ก, โ€ฆ) โ†’ ๐‘ก
One or more values of the same ordinal type
null when at least one value is null
min({๐‘ก, ๐‘ก, โ€ฆ})and max({๐‘ก, ๐‘ก, โ€ฆ}) ignore null values (see Q317)

Implementations may support opaque data types - data types for which the internal data representation is not exposed. For each opaque data type - a set of functions and operators may be defined (see location data type in Application: Spatiotemporality).

Quantifiers

A vertical purple rectangle represents a vertical quantifier. The text inside the rectangle denotes the quantifier type.

Vertical quantifiers (or simply โ€˜quantifiersโ€™) add much expressive power, including more complex topological constraints, more than one entityโ€™s expression constraint, and alternative subpatterns.

Q3: Any person whose first name is Brandon who owns a dragon (version 2)

V1

Q219: Any person who owns a white horse weighing more than 200 Kg

V1

Q304: Any person who owns a white horse and who owns a horse weighing more than 200 Kg

V1

The same graph-entity may match more than one pattern-entity. For example, Either the same horse or different horses may be assigned to B and C (this can be avoided: see identicality, nonidenticality, and order constraints later on). Similarly, the same graph-relationship may match more than one pattern-relationship.

A vertical quantifier has one connection on its left side and zero or more branches on its right side. On its left side is an entity, a quantifier, or the patternโ€™s start. Except at the patternโ€™s start, a quantifier may be wrapped with an โ€˜Oโ€™ (see Q147, Q360v2).

When a quantifier (or the rightmost quantifier in a sequence of quantifiers) is directly right of the pattern start, each branch may start with:

When a quantifier (or the rightmost quantifier in a sequence of quantifiers) is directly right of an entity, each branch may start with:

The following branches do not affect the quantifierโ€™s evaluation:

Each such branch is marked with a white triangle.

All other branches affect the quantifierโ€™s evaluation. Let ๐‘ denote the number of such branches.

We will name the left side of the quantifier the left component, and anything that follows a branch, up to the branchโ€™s end, a right component.

12 quantifier types are defined:

V1

The order of the branches does not affect the evaluation result.

Q8: Any person born before 970 and passed away or whose father was born not later than January 1, 950 (two versions)

V1

The personโ€™s death date is not null, nor is it inapplicable. When Aโ€™s death date is null, โ€˜deathDate โ‰  31/12/9999โ€™ is evaluated to unknown, and the constraint is not satisfied.

The following pattern also requires that Aโ€™s death date is not a future date:

V1

Q11: Any current member of the Masons Guild who, on or after January 1, 1011, befriended someone who had left the Saddlers guild or the Blacksmiths guild in June 1010 or later

V1

The constraint โ€˜member of df.till = 31/12/9999โ€™ means an inapplicable membership end date โ€“ the person is currently a member of the Masons guild.

Entity-Tags

The letter in the top-left corner of each pattern-entity rectangle (concrete, typed, or untyped) is called an entity-tag. Entity-tags are also included in query results: any graph-entity in a query result is annotated with the same tag as the pattern-entity to which it was assigned so that the query poser can understand why any given entity is part of the result. As part of the result, a graph-entity may be annotated with more than one entity-tag, as it may be assigned to several pattern-entities (in the same assignment or in different assignments - when assignments are merged).

Entity-tags may be referenced:

Identicality constraints can be used when the same graph-entity should be assigned to:

Q4: Any person A whose dragon was frozen by a dragon owned by (at least) one of Aโ€™s parents

V1

Entity-tag โ€˜Bโ€™ is used to enforce identical assignment to two Dragon pattern-entities.

Entity-tags with identicality constraints are depicted in green.

Q9: Any pair of dragons (A, B) where A froze B in both 980 and 984

V1

The same visual notation is also used when the same concrete entity appears more than once (see Q25v2, Q26v2)

Nonidenticality constraint can be used when different graph-entities should be assigned to typed entities of the same type or to untyped entities.

Q5: Any person A whose dragon was frozen by a dragon owned by two of Aโ€™s parents (version 1)

V1

Without the nonidenticality constraint, the same parent could be assigned to both D and E.

Nonidenticality constraints are depicted in red (โ€˜โ‰ Xโ€™), where X is another entity-tag. Several nonidenticality constraints may be defined for the same pattern-entity, e.g., โ€˜โ‰ A,โ‰ Cโ€™ (see Q57).

Q6: Any person A whose dragon was frozen by two dragons - one owned by one of Aโ€™s parents, the other owned by another parent (none, one, or both dragons may be owned by both parents)

V1

Q7: Any person A whose dragon was either (i) frozen by a dragon owned by two of Aโ€™s parents or (ii) frozen by two dragons - one owned by one of Aโ€™s parents and the other owned by Aโ€™s other parent

V1

Q24: Any person A having (at least) two parents and owns a dragon that was frozen by a dragon neither of Aโ€™s parents owns

V1

Q24 demonstrates the usage of both identicality and nonidenticality constraints for the same pattern-entity.

Consider Q5v1, Q6, Q7, and Q24. For any given assignment, there is another assignment where the two parents are switched (for example, in Q5v1, the assignments to D and E are switched). Such redundant assignments are usually undesired. Using order constraints, we can avoid such redundancies (see Q5v2).

Also, consider the following pattern: Any three persons A, B, and C, who are pairwise friends. If persons (A1, B1, C1) compose an assignment, so do (A1, C1, B1), (B1, A1, C1), and all other permutations. Such a factorial increase in the number of assignments is usually undesired. Using order constraints, we can express patterns such as Any three persons A<B<C, who are pairwise friends.

Order constraints can be used when graph-entities should be orderly assigned to either typed entities of the same type or untyped entities.

Q31: Any pair of dragons (A, B) where A froze B, A fired at B, B froze A, and B fired at A (version 1)

V1

Without the order constraint, any reported pair of dragons would be reported twice: (D1, D2), (D2, D1).

The property graph data model requires that entities be distinguishable. To support order constraints between pattern-entities of the same type, V1 further requires each set of graph-entities of the same type to be totally ordered. To support order constraints between pattern-entities of possibly different types (See Q51), V1 requires the set of graph-entities to be totally ordered.

Order constraints are depicted in red (โ€˜<Xโ€™ or โ€˜โ‰คXโ€™), where X is another entity-tag. Several nonidenticality or order constraints may be defined for the same pattern-entity, e.g., โ€˜<A,<Bโ€™, โ€˜โ‰ A,<Cโ€™ (see Q83).

See also Q49, Q88, Q115v1, Q272, Q337, Q342, Q347, and Q350.

If, for some assignment, an identicality, nonidenticality, or order constraint is not relevant (e.g., identicality constraint between a pair of entities in two branches of a Some quantifier, where the assignment includes only one branch) - the constraint is ignored. Otherwise - the assignment is valid only if the constraint is satisfied.

Negator

V1

Sometimes we need to express a pattern containing elements for which there is no assignment. For example, any person whose first name is Brandon and who does not own a white horse. Such patterns are composed of:

An assignment matches the pattern only if:

Such patterns can be composed using negators. The pattern starts with the โ€˜positiveโ€™ component, and negators separate it from the โ€˜negativeโ€™ components.

A negator is depicted by a narrow pink โ€˜Xโ€™ rectangle. The rectangle has one on its left side and one on its right side.

On its left, there is either

On its right is a relationship or a path (see Paths, Q84)

Query results do not include assignments to entities/relationships/paths right of a negator. Any pattern entity right of a negator is depicted with a gray โ€˜no reportโ€™ icon on its top-right, indicating that the query result does not include its assignment (see Latent pattern-entities).

Q12: Any person who does not own a horse

V1

Q13: Any horse not owned by a person

V1

Q14: Sweetfoot - if no person owns it

V1

Q15: Brandon Stark - if he does not own a horse

V1

Q16: Any person who does not own Sweetfoot

V1

Q17: Any horse not owned by Brandon Stark

V1

Q18: Brandon Stark - if he does not own Sweetfoot

V1

Q19: Sweetfoot - if Brandon Stark does not own it

V1

Q256: Any person who does not own a white horse

V1

Q257: Any person who did not become a horse owner in or after 1011

V1

Q258: Any person who did not become a white horse owner in or after 1011

V1

Q22: Any horse not owned by a person who owns a dragon

V1

The positive component is a horse, while the negative component is owned by a person who owns a dragon. The right component is anything that follows the negator - up to the end of the branch.

Valid assignments:

Q333: Any person who does not own a dragon that both fired at and froze the same dragon

V1

A negator may also appear left of a relationship that directly follows a quantifierโ€™s branch:

Q25: Any dragon (C) not fired at by Balerion but fired at by a dragon that Balerion fired at (two versions)

V1

V1

Q26: Any person who is a member of at least one guild that Brandon Stark is a member of and at least one guild that Brandon Stark is not a member of (four versions)

V1

V1

V1

V1

Negators may appear in more than one branch:

Q20: Any horse neither owned by Rogar Bolton nor by Robin Arryn (two versions)

V1

Note that there are two negative components. This query can also be represented using the None quantifier:

V1

Q21: Any horse not owned by both Rogar Bolton and Robin Arryn

V1

If either Rogar Bolton or Robin Arryn owns the horse - the owner will not be part of the reported assignments.

Q362: Any horse owned either by Rogar Bolton or Robin Arryn but not by both

V1

If either Rogar Bolton or Robin Arryn owns the horse - the owner will be part of the reported assignments.

Negators may also appear in a sequence:

Q23: Any horse not owned by a person who does not own a dragon

V1

The positive component is a horse, while the negative component is owned by a person who does not own a dragon. The right component is anything that follows the left negator - up to the end of the branch.

Valid assignments:

EA-tags, entity type-tags, and relationship type-tags defined right of a negator can only be referenced right of that negator.

Identicality, nonidenticality, and order constraints cannot be defined between pattern-entities in different negative components.

V1

Relationship/Path-Negator

V1

The pattern Any person whose first name is Brandon and who does not own a white horse has assignments in two cases:

Sometimes we want an assignment to match the pattern only in the second case - we want only assignments that match the whole pattern except for given relationships/paths. Hence, an assignment matches the pattern only if:

A relationship/path-negator is depicted with a red โ€˜โœ•โ€™ at the center of the relationship/path arrow/line. The arrow/line and the associated text are faded.

A component located right of a pattern relationship/path with a relationship/path-negator is required to have an assignment. Such assignments are included in the reported pattern assignment. The relationship/path is reported as a negated relationship/path, which may have a type and properties.

Q357: Any dragon for which there is at least one dragon (besides itself) it did not freeze

V1

Each assignment comprises a dragon, a negated freezes relationship, and a dragon it did not freeze.

Q83: Any dragon for which there are at least two dragons (besides itself) it did not freeze

V1

Q204: Any dragon for which there is a dragon not owned by a Sarnorian that did not freeze it

V1

Q205: Any dragon A and Sarnorian subject C where there is a dragon not owned by C that did not freeze A

V1

Relationship/path-negators are often used with aggregators (see Q126, Q63-Q66, Q165, Q298, Q345).

A relationship/path with a relationship/path-negator may be wrapped with a negator.

Q82: Any dragon that froze all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not freeze (version 1)

V1

Combiner

V1

A combiner combines two or more consecutive branches of the same quantifier.

A combiner is depicted by a narrow purple โ€˜}โ€™ rectangle. The rectangle has one connection on its left side and one on its right side.

On its left, there can be

On its right โ€“ there is either

The entity-type on a combinerโ€™s right side must match all the relationship-types and paths on its left side.

Q30: Any pair of dragons (A, B) where A both froze B and fired at B (two versions)

V1

A combiner is syntactic sugar, which, alternatively, can be implemented by duplicating anything right of it to each branch.

V1

Q187: Any dragon Balerion froze at least once on or after January 1, 1010, and at least once for less than ten minutes

V1

Note that the same graph-relationship may be assigned to both freezes pattern-relationships. Compare with Q185.

Q189: Any dragon Balerion froze at least once on or after January 1, 1010, or at least once for less than ten minutes

V1

Q29: Any dragon that froze or fired at some dragon (versions 1-3)

V1

Note that the implied identicality is redundant.

V1

V1

See also note under Q121v1 - combiner right of an A1 aggregator.

Q31: Any pair of dragons (A, B) where A froze B, A fired at B, B froze A, and B fired at A (version 2)

V1

Without the order constraint, any reported pair of dragons would be reported twice: (D1, D2), (D2, D1).

Q32: Any pair of dragons (A, B) where A fired at both B and some dragon that fired at B

V1

Q5: Any person A whose dragon was frozen by a dragon owned by two of Aโ€™s parents (version 2)

V1

Q170: Any three dragons (A, B, D) where A fired at B, A fired at some dragon that fired at B, B froze D, and B froze some dragon that froze D

V1

Q33: Any dragon A that froze some dragon B, froze some dragon that froze B, and fired at some dragon

V1

Different branches may be combined with different combiners.

Q34: Any dragon A that froze some dragon B, froze some dragon that froze B, fired at some dragon D, and fired at some dragon that fired at D (B and D may be the same dragon or different dragons)

V1

Q35: Any pair of dragons (A, B) where A froze B but did not fire at B

V1

At least one combined branch must be a non-negative component.

V1

For the None quantifier, all the branches are negative components.

V1

Chains, Horizontal Quantifiers, and Horizontal Combiner

Relationshipโ€™s expressions can be chained. When chained, each expression with a constraint is a filtering stage. An assignment is valid only if all the chained constraints are satisfied, or in other words - if it passes all filtering stages.

Q188: Any dragon Balerion froze at least once - on or after January 1, 1010, for less than ten minutes

V1

Q10: Any person whose first name is Brandon, who owns some dragon B which froze a dragon C that (i) belongs to an offspring of Rogar Bolton, and (ii) froze a dragon that belongs to either Robin Arryn or Arrec Durrandon. B froze C at least once in or after 1010 - for longer than 100 seconds

V1

A horizontal purple rectangle represents a horizontal quantifier. The text inside the rectangle denotes the quantifier type.

Eleven horizontal quantifier types are defined (as for vertical quantifiers, except the All quantifier). Their semantics are similar to those of vertical quantifiers. All can be implemented by chaining relationshipโ€™s expressions or by using vertical quantifiers (see Q100).

On the top of a horizontal quantifier, there can be

On its bottom, there are zero or more branches. Each branch starts with either

A branch composed of relationshipโ€™s expressions with no constraints does not affect the quantifierโ€™s evaluation.

A horizontal combiner may be used to combine two or more consecutive branches of the same horizontal quantifier. Each branch ends with either

Below a horizontal combiner, there can be either

Q300: Any pair of dragons (A, B) where A froze B, and at least two of the following conditions are satisfied: (i) the freeze duration was longer than ten minutes, (ii) the freeze started after January 1, 980, and (iii) the freeze ended before February 1, 980

V1

Q301: Any pair of dragons (A, B) where A froze B for more than ten minutes, and either the freeze started after January 1, 980, or the freeze ended before February 1, 980 (two versions)

V1

V1

See also Q267v3.

Latent Pattern-Entities

V1

Pattern entities may be annotated as implicit latent or explicit latent.

Assignments to latent pattern-entities and assignments to pattern-relationships and pattern-paths connected to latent pattern-entities are not included when pattern assignment is reported.

Implicit latent pattern-entities are pattern-entities that appear

Such typed and untyped entities are required to have no assignments; hence, trivially, no assignments would be reported. Such concrete entities would not be reported as well (see Q20).

Implicit latent pattern-entities are depicted with a gray โ€˜no reportโ€™ icon on their top-right. These icons are automatically added by the interactive pattern-builder/visualizer tool and may not be added/removed by the pattern composer.

An entity right of a combiner is not depicted as implicit latent even if it is implicit latent according to one or more branches (see Q35).

Explicit latent pattern-entities are non-implicit latent pattern-entities, which the pattern composer marks as latent. Though they may have assignments - those assignments are required not to be reported. Any non-implicit latent pattern-entity may be set as explicit latent.

Explicit latent pattern-entities are depicted with a red โ€˜no reportโ€™ icon on their top-right.

Q142: Any person who owns a white or a black horse and has a parent who owns a dragon. The parent and its dragon are not to be included in the reported assignment

V1

Suppose person A1 has two parents, each with four owns relationships to dragons. Without the latent annotations, there would be eight pattern assignments per person and owns relationship to a horse. With the latent annotations, there would be only one assignment per person and owns relationship to a horse.

Q143: Any person who owns a horse that is neither white nor black and has a parent that does not own a horse. The parent is not to be included in the reported assignment

V1

When several pattern-entities have the same entity-tag, some may be latent (implicit or explicit) while others are not. See Q337, Q339.

Concrete, typed, and untyped entities may all be latent - implicit or explicit.

At least one pattern-entity should be non-latent.

Optional Components

V1

Anything right of an optional is optional: if it has a valid assignment - it will be reported (unless it is latent). Otherwise - it will not.

An optional (i.e., an โ€˜Oโ€™) is depicted with a magenta โ€˜Oโ€™ rectangle. The rectangle has one connection on its left side and one on its right side.

On its left, there is either

On its right, there is either

Alternatively:

On its left is a quantifier at the start of the pattern, and on its right is an entity (see Q321v1)

Q147: Any person A. If A owns both a horse and a dragon - they should be included in the assignment

V1

Q149: Any person A. If A owns a horse - it should be included in the assignment. If A owns a dragon - it should be included in the assignment as well

V1

Q81: Balerion. If there is a dragon it did not freeze - it should be included in the assignment

V1

Quantifierโ€™s branches that start with an โ€˜Oโ€™ do not affect the quantifierโ€™s evaluation.

Assignments to optional branches are reported regardless of the quantifier type, but only when there is an assignment to the pattern.

Q144: Any person A who owns a white horse. If A has a parent who owns a horse - the parent and its horse should be included in the assignment

V1

Q145: Any person A who owns a white horse. If A has a parent that does not own a horse - the parent should be included in the assignment

V1

Q146: Any person A who owns a white horse. If A has a parent - the parent should be included in the assignment. If Aโ€™s parent owns a horse - this horse should be included in the assignment as well

V1

Q148: Any person A who owns both a horse and a dragon. If A has a parent - the parent should be included in the assignment

V1

Q150: Any person A who owns a horse or a dragon. If A has a parent - the parent should be included in the assignment

V1

Q203: Any person A. If A owns both a horse and a dragon - they should be included in the assignment. If A owns both a horse and a dragon and also has a parent - the parent should be included in the assignment as well

V1

Q359: Any dragon A where (i) there is no black dragon A froze, (ii) there is no white dragon A did not freeze, (iii) there is at least one gold dragon A froze, and (iv) there is at least one silver dragon A did not freeze. Also, report any red dragon that A froze and any blue dragon that A did not freeze

V1

When tags right of an โ€˜Oโ€™ have no assignments:

Entity-tags defined right of an โ€˜Oโ€™ cannot be used in identicality, nonidenticality, and order constraints defined left of the โ€˜Oโ€™.

Entity type-tags, defined right of an โ€˜Oโ€™ cannot be used in entity-type constraints defined left of the โ€˜Oโ€™.

Relationship type-tags defined right of an โ€˜Oโ€™ cannot be used in relationship-type constraints defined left of the โ€˜Oโ€™.

Entity-tags, entity type-tags, and relationship type-tags defined right of an โ€˜Oโ€™ can be used in aggregators defined left of the โ€˜Oโ€™:

Untyped Entities

A relationship-type may hold between different pairs of entity-types (e.g., owns: {(Person, Dragon), (Guild, Dragon), (Null, Dragon)}). Untyped entities can be used to express patterns such as Any dragon and its owners, where the owner can be either a person, a guild, or Null.

A red rectangle represents an untyped entity. Graph-entities of different types may be assigned to an untyped entity.

A red rectangle containing only an entity-tag represents an entity with no explicit entity-type constraint.

Q36: Any person who owns something

V1

B assignments are implicitly type-constrained to things that a person can own.

Implicit entity-type constraints are inferred from the pattern, including from identicality, nonidenticality and order constraints.

Q49: Any three dragons with a cyclic freeze pattern and their owners (if any)

V1

The entity-types of all owners are implicitly constrained to things that can own a dragon.

Entities are implicitly type-constrained also when untyped entities are on either side of a negator or a relationship-negator:

Q39: Any entity of a type that can own a dragon but does not

V1

Q40: Any dragon that is not owned

V1

Q41: Any entity of a type that can be owned but is not owned

V1

Q42: Any entity of a type that can own something but owns nothing

V1

In addition to the implicit entity-type constraints, explicit entity-type constraints can be enforced using:

Q43: Any dragon that all of its owners (if any) are people

V1

Q37: Any person who owns a horse or a dragon

V1

Q38: Any person who owns something which is neither a horse nor a dragon

V1

For each untyped entity, implicit and explicit type constraints must not nullify the list of valid entity-types. Explicit type constraints must not contradict implicit type constraints. This can be asserted during query analysis.

Since both horse and dragon entity-types have a name property of the same data type (string) - the following pattern is valid:

Q291: Any person who owns a horse or a dragon whose name starts with an โ€˜Mโ€™

V1

Entity Type-Tags

V1

A red rectangle (denoting an untyped entity) may contain an entity type-tag, depicted by a numeric index wrapped in angle brackets. An entity type-tag represents the entity-type of the entity in a given assignment.

Entity type-tags may be referenced:

Q50: Any person who owns (at least) two things of the same type

V1

Q51: Any person who owns (at least) two things of different types

V1

Q52: Any person who owns (at least) two things of different types, neither is a horse

V1

Q167: Any person whose owned entities are all of the same type (version 1)

V1

For any quantifier except All - an entity type-tag defined in a branch can only be referenced in that branch.

V1

An entity type-tag defined right of a negator can only be referenced right of that negator.

V1

An entity type-tag defined right of an โ€˜Oโ€™ can only be referenced right of that โ€˜Oโ€™, except when used in an aggregatorโ€™s ๐‘‡ (any aggregator) or ๐‘€ (A3, M1, M2, M3 aggregators) definition.

Untyped Relationships

Multiple relationship-types may hold between a pair of entity-types (e.g., freezes: {(Dragon, Dragon)}, fires at: {(Dragon, Dragon)}. Untyped relationships can be used to express patterns such as Any pair of dragons with at least one relationship, where the relationship-type can be either freezes or fires at.

A red arrow/line with no type label or with type constraints represents an untyped relationship. Graph-relationships of different types may be assigned to an untyped relationship.

A red arrow/line with no label represents a relationship with no explicit type constraints:

Q29: Any dragon that froze or fired at some dragon (version 4)

V1

The relationship is implicitly type-constrained to directional relationship-types between two dragons.

Q53: Any person with a path of length up to three to Rogar Bolton (version 1)

V1

Relationships are implicitly type-constrained also when a negator or a relationship-negator wraps an untyped relationship:

Q360: Any dragon that (froze or fired at) all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not (freeze or fire at) (version 1)

V1

In addition to the implicit relationship-type constraints, explicit relationship-type constraints can be enforced using:

Q364: Any person and an entity that have a relationship of a type other than โ€˜friend ofโ€™

V1

Implicit relationship-type constraints are inferred from the pattern (including from relationships directionality and from entities identicality/nonidenticality/order constraints).

For each untyped relationship, implicit and explicit type constraints must not nullify the list of valid relationship-types. Explicit type constraints must not contradict implicit type constraints. This can be asserted during query analysis.

Relationship Type-Tags

V1

Instead of a relationship-type, a relationship label may denote a relationship type-tag, depicted by a numeric index wrapped in double angle brackets. A relationship type-tag represents the relationship-type of the relationship in a given assignment.

Relationship type-tags may be referenced:

Q365: Any pair of dragons that have relationships of at least two types

V1

Q366: Any pair of dragons that have relationships of at least three types (version 1)

V1

Since there are only two relationship-types between a pair of dragons (freezes, fires at), this pattern would never have assignments. This can be detected during query analysis.

Q367: Any pair of dragons that have a directional relationship of the same type in both directions

V1

Q368: Any pair of dragons that have relationships of at least two types, neither is โ€˜freezesโ€™

V1

Again, the fact that this pattern would never have assignments can be detected during query analysis.

For any quantifier except All - a relationship type-tag defined in a branch can only be referenced in that branch.

A relationship type-tag defined right of a negator can only be referenced right of that negator.

A relationship type-tag defined right of an โ€˜Oโ€™ can only be referenced right of that โ€˜Oโ€™, except when used in an aggregatorโ€™s ๐‘‡ (any aggregator) or ๐‘€ (A3, M1, M2, M3 aggregators) definition.

Null Entities

As described above, graph-entities of type Null realize action-types and relationships to unknown/unimportant entities.

Since each graph-entity of type Null is connected by exactly one relationship, there are additional implicit constraints on each typed entity of type Null and on each untyped entity that explicitly allows type Null:

As part of a pattern:

As part of an assignment:

See G1-G20.

Paths

A graph-path is a sequence of graph-entities and graph-relationships that starts with a graph-entity and ends with a graph entity. A simple graph-path is a graph-path where all entities are pairwise distinct, except, possibly, the first and last.

Each graph-path has a length. The path length is equal to the number of graph-relationships along the path; hence, a relationship is a path of length 1.

A pattern-path connects two pattern-entities - like a pattern-relationship. However, while a pattern-relationships are assigned with graph-relationships, pattern-paths are assigned with simple graph-paths minus the first and last entities, which are not considered a part of the assignment. Thus, pattern-paths are assigned with at least one graph-relationship.

A blue line between two pattern-entities represents a pattern-path. Above the line is a constraint on the path length. An upper bound on the path length must be defined, hence the constraint must be defined using one of the following constraint types: = expr, < expr, โ‰ค expr, in set-expr, in bag-expr, in list-expr, or in interval-expr, where all expressions or interval bounds evaluate to positive integers.

Q53: Any person with a path of length up to three to Rogar Bolton (version 2)

V1

Q84: Any dragon with no paths of length up to three to other dragons

V1

Q55: Any entity with paths of length up to three to Rogar Bolton, Robin Arryn, and Arrec Durrandon

V1

Constraints may be defined for both the entities and the relationships along the path:

Constraints on relationships along the path are listed in blue curly brackets above the pathโ€™s line. The brackets may list either:

Constraints on entities along the path are listed in blue curly brackets below the pathโ€™s line. The brackets may list either:

A path cannot be composed of Null entities since they are terminal nodes. Therefore, the list of allowed entity-types may not contain Null. Similarly, the list of disallowed entity-types may not contain Null as it is implicitly disallowed.

Q44: Any path of length up to four between Vhagar and Balerion, which is composed only of โ€˜freezesโ€™ relationships

V1

Q45: Any path of length up to four between Vhagar and Balerion composed only of โ€˜freezesโ€™ and โ€˜fired atโ€™ relationships

V1

Q46: Any path of length up to four between a dragon owned by Rogar Bolton to a dragon owned by Robin Arryn, which is composed of up to two โ€˜freezesโ€™ relationships and only of โ€˜Dragonโ€™ entities

V1

Q54: Any person with paths of length up to three to Rogar Bolton, Robin Arryn, and Arrec Durrandon. The paths composed only of โ€˜friend ofโ€™ relationships

V1

Shortest Paths

Instead, or in addition to specifying a constraint on the path length - a shortest path constraint can limit paths-assignments to the shortest ones that subject to the constraints on the entities/relationships along the path. If, for example, the length of the shortest path that subjects to the constraints is three - only paths of length three are valid assignments.

Q47: All shortest paths between Vhagar and Balerion

V1

Q48: All shortest paths between Vhagar and Balerion, which are neither composed of โ€˜freezesโ€™ relationships nor โ€˜Dragonโ€™ entities (version 1)

V1

shortest may not appear directly right of a negator or a path-negator.

Path Patterns

An alternative to constraints on the entity-types and the relationship-types along a path are constraints on the subgraphs which assignments to a path are composed of.

A path pattern is a pattern that has one entity marked as left-terminal and one entity, possibly the same one, marked as right-terminal.

A path-assignment is composed of chained subgraphs; each subgraph is assigned to a path pattern. There is an overlap between assignments to successive path patterns:

A blue table below the path defines constraints on the pathโ€™s path pattern types. The table has two columns:

The last row defines whether a path-assignment may be composed of other graph-elements (โ€˜โœ”โ€™ if yes, โ€˜โœ˜โ€™ if no).

Q48: All shortest paths between Vhagar and Balerion, which are neither composed of โ€˜freezesโ€™ relationships nor โ€˜Dragonโ€™ entities (version 2)

V1

Q58: Any Sarnorian who has a path of length up to six to an Omberian. The path passes through Rogar Bolton

V1

Q56: constraints on path patterns

In this example, path assignments must be composed of assignments to four path patterns

V1

Q57: constraints on path patterns

V1

Q322: Any dragon owned by at least five consecutive generations of the same dynasty

V1

Q323: Any dragon owned by at least five (not necessarily consecutive) generations of the same dynasty

V1

See also Q290, Q329.

Referencing Expression-Tags

V1

Each green rectangle has an expression-tag on its top-left corner, depicted by an index wrapped in curly brackets (โ€˜{xt}โ€™). An expression-tag represents the result of the evaluation of an entityโ€™s expression, relationshipโ€™s expression, or Cartesian productโ€™s expression - for a given assignment.

Expression-tags and aggregation-tags are jointly called EA-tags. Each EA-tag has a unique positive integer index. If an EA-tag is referenced at least once - it is depicted in bold purple. Otherwise - it is depicted in black.

Expression-tags may be referenced:

Q108: Any person who has the same birth date as Brandon Stark

V1

{1} is a property of the only assignment to A. {2} is a property of each unique assignment to B.

For any quantifier except All:

V1

Similarly, for any horizontal quantifier except All:

For each entity/relationship/Cartesian product - if the same expression is used more than once - the same expression-tag will be assigned (see also Q267v3, Q311):

V1

V1

Self or circular references are invalid:

V1

V1

Q111: Any person A who has no friends with whom A shares a birthdate

V1

An EA-tag defined right of a negator can only be referenced right of that negator.

V1

Q353: Any person A that in the day A turned two years old - at least one person was born, but there is no such person A became a friend of since A reached 20

V1

A relationshipโ€™s expression defined below a relationship-negator can only be referenced in that chain.

V1

Composite properties and subproperties are tagged and can be referenced similar to ordinary properties:

Q109: Any person A whose parent owned a horse or a dragon before Aโ€™s birth (two versions)

V1

V1

Q110: Any three dragons with cyclic freezes of more than 100 minutes, in chronological order, within six months, and their owners (if any)

V1

Q112: Any person who owned a horse and a dragon at the same timeframes (three versions)

V1

The subproperties can be compared one-by-one:

V1

The order of the expressions along a chain does not matter. The following representation is valid, as well:

V1

Q266: Any person A who has the same name (first and last) as Aโ€™s parent (two versions)

V1

V1

Q267: Any person who was a member of two guilds at overlapping timeframes (three versions)

V1

V1

The following version also covers some cases where one membership has either a null (unknown) start date or a null (unknown) end date:

V1

Aggregators

One can use an order constraint to represent patterns such as Any person who owns at least two horses, but it is quite cumbersome for patterns such as Any person who owns at least 20 horses. Patterns such as Any dragon that froze dragons more than ten times or Any dragon that froze dragons for a cumulative duration longer than 100 minutes cannot be expressed without aggregators.

An orange rectangle represents an aggregator. It is composed of two parts:

V1

Here are three examples:

First example: Any person who owns at least 20 horses (Q59)

V1

All assignments to the pattern, ignoring the aggregator, are found, and split into sets. In each set, all the assignments to A are identical. Only sets with more than 20 assignments to B are valid pattern assignments.

Second example: Any dragon that froze dragons more than ten times (Q71)

V1

All assignments to the pattern, ignoring the aggregator, are found, and split into sets. In each set, all the assignments to A are identical. Only sets with more than ten assignments to the relationship are valid pattern assignments.

Third example: Any pair of dragons (A, B) where A froze B for a cumulative duration longer than 100 minutes (Q86)

V1

All assignments to the pattern, ignoring the aggregator, are found, and split into sets. In each set, all the assignments to both A and B are identical. Only sets where the sum of the duration of all freezes relationships is greater than 100 minutes are valid pattern assignments.

Evaluating an aggregator:

Next, we will define three aggregator types: A1, A2, and A3. Steps 1, 2, 4, and 5 are identical for all types. Step 3 is different, as sets are aggregated in different ways.

Let ๐‘† denote the set of all assignments to the pattern excluding this aggregator (subject to aggregators evaluation order) (that is step 1 above).

V1

Upper part

Let ๐‘‡ denote a Cartesian product of one or more entity-tags.

For all aggregator types (A1, A2, A3, M1, M2, M3, and R1), the per clause has one of the following formats:

Wherever possible, the notations โ€˜โ†โ€™, โ€˜โ†’โ€™ and โ€˜โŸทโ€™ are used instead of entity-tags.

Next, let TA denote a of all unique assignments to ๐‘‡ in ๐‘†. TA[n] is the nโ€™th unique assignment to ๐‘‡.

Let S(n) denote a subset of ๐‘†: the set of all assignments composed of TA[n] (that is step 2 above).

The upper part is optional. When there is no upper part - ๐‘† is not split.

Lower part

The lower part contains an aggregation-tag, an aggregate expression, and optionally a constraint on the result of the evaluation of the aggregate expression.

The aggregation-tag is on the top-left corner and is depicted by an index wrapped in curly brackets (โ€˜{at}โ€™). An aggregation-tag represents the result of the evaluation of the aggregate expression for a given set of assignments.

For each entity/relationship/Cartesian product - if the same expression/aggregation is used more than once - only one EA-tag will be assigned (see Q64, Q73v2, Q82v2).

at is evaluated per each TA[n]. In the first example above, {1} is evaluated per each unique assignment to A in ๐‘†. at is a calculated property of TA[n]. When there is no upper part - at is a global property (see {1} in Q82v3, {1} in Q372, {2} in Q356).

Aggregation-tags may be referenced:

A1 Aggregator

V1

Let ๐ต denote a list of Cartesian products of entity-tags. ๐ต must be nonempty and must not be composed of entity-tags composing ๐‘‡.

The lower part of an A1 aggregator contains the following elements:

A1 location:

Q59: Any person who owns at least 20 horses

V1

{1} is a property of each unique assignment to A in ๐‘†.

Q60: Any dragon that was frozen by exactly five dragons

V1

If some dragon B froze some dragon A more than once - B would still be counted only once per A. A1 counts distinct entity assignments.

Q61: Any entity that owns more than two entities

V1

Q62: Any person who has paths of length up to four to more than five people

V1

Q136: Any dragon A that froze (dragons that froze dragons B). The cumulative number of distinct Bs (per A) is greater than 100 (two versions)

V1

V1

Q177: Any dragon A frozen by at least ten dragons and froze each of those (two versions)

V1

First, any pair (A, B) matching the pattern excluding the aggregator is found. Then, the aggregation constraint is checked: For each assignment to A, there are at least ten assignments to B.

V1

First, any pair matching the pattern excluding the aggregators is found. Then, the aggregation constraints are checked one by one:

For each assignment to A:

Q178: Any dragon A either (i) frozen by exactly ten dragon and froze at least one dragon which is not one of those, (ii) frozen by exactly ten dragon and froze at least two of those, or (iii) frozen by more than ten dragons and froze at least one dragon

V1

First, any dragon triplet (A, B, C) matching the pattern excluding the aggregator is found. Then, the aggregation constraint is checked:

For each assignment to A, there are at least ten assignments to B such that (B froze A, and A froze a dragon that is not B)

Q85: Any dragon that froze at least ten dragons and was frozen by at least ten dragons (two versions)

V1

V1

First, any dragon triplet (A, B, C) matching the pattern excluding the aggregators is found. Then, the aggregation constraints are checked one by one:

For each assignment to A:

Hence, for each assignment to A:

Hence, A froze at least ten dragons, and at least ten dragons froze A

Q101: Any person who owns at least five white horses

V1

Q102: Any dragon A that was frozen by exactly two dragons, each of which was frozen at least once. A might have been frozen by additional dragons that were never frozen

V1

Q166: Any dragon that more than five Sarnorians own a dragon that froze it

V1

Q246: Any dragon B that froze at least one dragon and was frozen by more than ten dragons

V1

{1} is a property of each unique assignment to B in ๐‘†.

Q247: Any dragon C that more than ten dragons froze dragons that froze it

V1

Q113: Any person A who has at least five friends with whom A shares a birthdate

V1

Q114: Any person who owns at least five horses of the same color (versions 1, 2)

V1

B is explicit latent to avoid redundant results. Were B not latent, each pattern assignment would have one of Aโ€™s dragons assigned to B and all Aโ€™s dragons of the same color assigned to C. When B is latent, all such reported results are identical, hence, reported only once.

The following pattern avoids redundant results as well:

V1

Q218: Any person who owns at least five entities of the same type (version 1)

V1

Q292: Any person A that at least 80% of Aโ€™s horses are black

V1

Q63: Any Masons Guild member who more than fifty Masons Guild members are not friends of

V1

Q65: Any person A who does not own more than two things that (at least) one of Aโ€™s parents owns/owned

V1

Q66: Any person from whom more than five people do not have a path of length up to six

V1

Q151: Any horse owned by more than ten people, at least one is Sarnorian. Only the Sarnorian owners should be reported

V1

Q152: Any horse owned by more than ten people. Only the Sarnorian owners should be reported

V1

Q125: Any dragon that the number of dragons it froze is greater than the number of dragons that froze it

V1

{1} is evaluated to zero when the optional part has no valid assignments.

Q126: Any dragon that the number of dragons it froze is greater than the number of dragons it did not freeze

V1

Q249: Any triplet of sets (people A, dragons B, horses C) where (i) any person in A owns at least one dragon in B and at least one horse in C, (ii) any dragon in B is owned by at least ten people in A, and (iii) any horse in C is owned by at least ten people in A

V1

Q250: Any triplet of sets (people A, dragons B, horses C) where (i) any person in A owns at least one dragon in B or at least one horse in C, (ii) any dragon in B is owned by at least ten people in A, and (iii) any horse in C is owned by at least ten people in A

V1

Q344: Any triplet of sets (people A, dragons B, horses C) where (i) any person in A owns at least one dragon in B and at least one horse in C, (ii) any dragon in B is owned by at least ten people in A, and (iii) any horse in C is owned by less than five people in A

V1

Q345: Any triplet of sets (people A, dragons B, horses C) where (i) any person in A owns at least one dragon in B and does not own at least one horse in C (ii) any dragon in B is owned by at least ten people in A, and (iii) any horse in C is not owned by at least ten people in A

V1

Q82: Any dragon that froze all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not freeze (version 2)

V1

The dragons that were frozen will not be a part of the assignment.

Q360: Any dragon that (froze or fired at) all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not (freeze or fire at) (version 2)

V1

Q64: Any dragon that no more than four dragons owned by Sarnorians did not freeze it

V1

Q165: Any dragon that no more than four Sarnorians own a dragon that did not freeze it

V1

Q206: Any dragon A that for each of no more than four Sarnorians C there is a dragon C does not own that did not freeze A

V1

Q305: Any person A that the number of horses A owns plus the number of dragons A owns - is at least ten (two versions)

V1 V1

Q121: Any dragon that froze or fired at at least ten dragons (two versions)

V1

โ€˜โ†’โ€™ is the entity directly right of the combiner.

V1

Note that any dragon that was both frozen and fired at - would be counted only once.

Q122: Any dragon that fired at dragon B and fired at a dragon that fired at B - for at least ten different Bโ€™s

V1

Q294: Any dragon that fired at Balerion and at least nine other dragons

V1

Q175: Any dragon that froze some dragon at least once and fired at some dragon at least once. The number of dragons it froze/fired at โ€“ is at least ten

V1

Note that if a dragon were both froze and fired at - it would be counted only once. A1 counts distinct entity assignments.

Q298: Any dragon A where (i) there is at least one black dragon A froze (ii) there is at least one white dragon A did not freeze, (iii) there is no gold dragon A froze, (iv) there is no silver dragon A did not freeze, and (v) the number of black or red dragons A froze plus the number of white and blue dragons A did not freeze - is at least ten. Report all black and red dragons that A froze and all white and blue dragons that A did not freeze

V1

Note that the entities that are right of a negator are not aggregated, but the entities that a right of a relationship/path-negator and no negator are aggregated. Compare with Q358.

Q176: Any dragon that either (i) froze at least one dragon and fired at at least one dragon it did not freeze. The number of dragons it froze/fired at is at least ten, or (ii) froze at least ten dragons

V1

Q293: Any person A that at least 80% of the horses owned by A and/or by (at least) one of Aโ€™s parents - are jointly owned by A and by (at least) one of Aโ€™s parents

V1

Q288: Any person A who owns a dragon that froze more dragons than any dragon owned by any of Aโ€™s ancestors

V1

Q290: Any path of length up to ten between Rogar Bolton and Robin Arryn that does not contain hubs (in this pattern - hubs are entities with degree โ‰ฅ 1000)

V1

Q329: Any Sarnorian who has paths of length up to six to more than five Omberians, Each of these paths passes through Rogar Bolton

V1

Q295: Any person A that the number of dragons A owns plus the number of dragons A does not own that Aโ€™s dragons fired at - is at least ten

V1

Note that if any of Aโ€™s dragons were fired at one of Aโ€™s other dragons - it would not be counted twice.

Q248: Any pair of dragons (A, C) where A froze more than ten dragons that froze C

V1

{1} is a property of each unique assignment to A ร— C in ๐‘†.

Q243: Any pair of people (A, D) where at least five of Aโ€™s dragons froze one or more Dโ€™s dragons

V1

Q244: Any pair of people (A, D) where at least five of Aโ€™s dragons froze Dโ€™s dragons, and at least five Dโ€™s dragons were frozen by one or more Aโ€™s dragons

V1

Q27: Any person A where there are less than 500 horses (combined) of the same colors as Aโ€™s owned horses

V1

Q28: Any person who owns a horse of a rare color (there are less than 500 horses of that color)

V1

Patterns Q346, Q352, and Q355, are similar in structure, but the aggregation is different:

Q346: Any dragon that froze at least ten dragons of the colors of horses of its owners

V1

Q352: Any dragon that froze at least ten dragons of the colors of horses of one of its owners

V1

Q355: Any dragon that froze at least ten dragons of the color of one horse of one of its owners

V1

Q335: Any person and that personโ€™s parent for whom there is no horse that both are its owners

V1

Q334: Any dragon A for which there is no dragon B that A both froze and fired at

V1

Q207: Any pair of dragons where the difference between the number of dragons that one of them froze and the number of dragons that the other froze is less than 10

V1

{3} is a property of each unique assignment to A ร— C in ๐‘†.

Q279: Any pair of people (A, E), each own dragons, where no Aโ€™s dragon froze any of Eโ€™s dragons

V1

Q82: Any dragon that froze all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not freeze (version 3)

V1

{1} is a global property.

In contrast to Q82v1 and Q82v2, the frozen dragons will be a part of the assignment.

Q360: Any dragon that (froze or fired at) all other dragons. Alternative phrasing: Any dragon for which there is no dragon (besides itself) it did not (freeze or fire at) (version 3)

V1

Q375: The difference between the number of white dragons and the number of black dragons

V1

{2}, {4} and {5} are global properties. {5} is a global expression.

A2 Aggregator

V1

Let ๐‘… denote a list where each element is a pattern-relationship/pattern-path. ๐‘… must be nonempty.

The lower part of an A2 aggregator contains the following elements:

A2 location:

Q71: Any dragon A that froze dragons more than ten times

V1

Q72: Any dragon A that was frozen exactly ten times (two versions)

V1

V1

Q73: Any dragon that did not freeze dragons or froze dragons no more than ten times (two versions)

V1

V1

Q123: Any dragon that either froze or fired at dragons - at least ten times

V1

(Per assignment to A - counting the number of assignments to the relationship directly right of the quantifier)

Q104: Any person who owned white horses at least ten times (same or different horses)

V1

Q296: Any person who owned horses at least ten times - each horse is either white or weighs more than 100 Kg (two versions)

V1

V1

If B and C are assigned with the same graph-entity (a white horse that weighs more than 100 Kg), identical assignments to the two owns relationships would be counted only once. A2 counts distinct relationship/path assignments.

Q79: Any person with more than five paths of length up to four to other people

V1

Q105: Any dragon A that was frozen exactly two times by dragons, each of which was frozen at least once. A might have been frozen by additional dragons that were never frozen

V1

Q245: Any dragon B that was frozen at least once and froze dragons exactly twice

V1

Q185: Any dragon Balerion froze at least once on or after January 1, 1010, at least once for less than ten minutes, and at least twice (on or after January 1, 1010, or for less than ten minutes)

V1

(counting the number of distinct freezes relationships)

Q127: Any dragon that froze dragons owned by Sarnorians more times than dragons owned by Omberians

V1

Q339: Any dragon Balerion froze more than ten times; report only those freezes that are in or after 1010

V1

Q297: Any dragon that the number of times it fired at dragons plus the number of paths of length up to three between it and some horse - is at least ten

V1

Q124: Any dragon that either (froze a dragon) or (fired at a dragon that fired at a dragon) - at least ten times

V1

Q173: Any dragon that fired at at least two dragons and fired at least ten times

V1

(counting the number of distinct fired at relationships). C is explicit latent to avoid redundant results (any dragon fired at would be assigned at least once to B and at least once to C).

Q174: Any dragon that either (i) froze at least one dragon and fired at at least one dragon it did not freeze, or (ii) froze at least two dragons. If (i): the number of times it froze/fired at dragons is at least ten; otherwise: the number of times it froze dragons is at least ten

V1

Q75: Any pair of dragons (A, B) where B froze A between eight and ten times

V1

Q76: Any dragon that froze Balerion between eight and ten times

V1

Q242: Any pair of people (A, D) where at least five times one of Aโ€™s dragons froze one of Dโ€™s dragons

V1

Q358: Any dragon A where (i) there is at least one black dragon A froze (ii) there is at least one white dragon A did not freeze, (iii) there is no gold dragon A froze, (iv) there is no silver dragon A did not freeze, and (v) the number of times A froze black and red dragons is at least ten. Report all black and red dragons that A froze

V1

Pattern-relationships that are wrapped with a negator and pattern relationships with a relationship/path-negator are not aggregated. Compare with Q298.

Q372: The number of times dragons were frozen

V1

{1} is a global property.

A3 Aggregator

V1

The lower part of an A3 aggregator contains the following elements:

A3 location:

When units of measure are defined for the expression (based on the aggregation operator, on the units of measures of the properties, and on the operators that compose the expression) - they are depicted as well (see Q86, Q117).

Q86: Any pair of dragons (A, B) where A froze B for a cumulative duration longer than 100 minutes

V1

Q87: Any dragon that was frozen at least once, and the cumulative duration it was frozen is less than 100 minutes

V1

Q89: Any dragon that froze dragons for more than three different durations

V1

Q167: Any person whose owned entities are all of the same type (version 2)

V1

Q366: Any pair of dragons that have relationships of at least three types (version 2)

V1

Q117: Any person whose owned horsesโ€™ average weight is greater than 450 Kg

V1

If a horse were owned twice - it would be counted only once.

Q116: Any person A that the number of distinct colors of Aโ€™s owned horses - is between one and three

V1

distinct does not aggregate null evaluation results. If all dragons have a null color, {2} would be equal to zero.

Q134: Any person A that the number of distinct colors of all horses owned by Aโ€™s friends - is between one and three

V1

Q229: Any person A that the number of distinct colors of all horses owned by Aโ€™s friends and parents - is between one and three

V1

Q135: Any person A that the average weight of all horses owned by Aโ€™s friends - is greater than 450 Kg

V1

Note that if some person A1 is a friend of two people who jointly own a horse, this horseโ€™s weight would be counted once.

Q137: Any dragon A that froze dragons B. Each B froze at least one dragon, which is not A. All these Bโ€™s together froze dragons for more than 100 minutes cumulatively

V1

Q336: For each dragon: each time it froze some dragon for a duration longer than the average duration of all its freezes

V1

First, any triplet (A, B, C) matching the pattern excluding the aggregator and the constraint in {2} is found. Then, {1} is evaluated per assignment to A, and then the constraint in {2} is evaluated per relationship assignment. See also Q337.

Note that a dragon that always froze dragons for the same duration is not a valid assignment to A.

Q354: Any dragon that froze one dragon and fired at another dragon, or froze a dragon and fired at more than one dragon, or fired at a dragon and froze more than one dragon, and there is some dragon that the earliest time it fired at it is earlier than the earliest time if froze any other dragon

V1

Q139: Any person A who owns horses of the same number of colors as the number of colors of the horses owned by Aโ€™s parents cumulatively

V1

Q98: Any pair of dragons (A, X) where A froze more than three dragons and (A froze X more than ten times or for a cumulative duration of more than 100 minutes)

V1

Q88: Any pair of dragons (A, B) where the cumulative duration A froze B is equal to the cumulative duration B froze A

V1

A property of entity et cannot be aggregated per et, nor per a superset of et.

V1

{1} is a property of B and hence cannot be aggregated per A ร— B.

If entity et has a property that references

then

V1

V1

In the two patterns above, {2} - a property of A, is referencing an aggregation of a property of a relationship between A and B. Therefore, a property of A cannot be constrained by a property of B. Similarly, a property of B cannot be constrained by a property of A.

V1

V1

In the two patterns above, {2} - a property of B, is referencing an aggregation of a property of a relationship between A and B. Therefore, a property of B cannot be constrained by a property of A. Similarly, a property of A cannot be constrained by a property of B.

Min/Max Aggregators

Sometimes we need to limit assignments to a Cartesian product of entity-tags, based on some value, to [all but] the ๐‘˜ assignments for which the value is the lowest/highest. Here are some examples:

Three types are M aggregators are presented:

M1 and M2 are syntactic sugar, which, alternatively, can be implemented by chaining A1 or A2 to an M3.

M1 Aggregator

V1

Let ๐ต denote a Cartesian product of one or more entity-tags. ๐ต must be nonempty and must not be composed of entity-tags composing ๐‘‡.

Let ๐‘€ denote a list of Cartesian products of entity-tags. ๐‘€ must be nonempty and must not be composed of entity-tags composing ๐ต or ๐‘‡.

The lower part of an M1 aggregator contains the following elements:

For each ๐‘›: from the set of assignments in S(n) - [all but] the ๐‘˜ assignments BA(n)[k] with the minimal/maximal positive card(MC(n, k)) are reported.

If there are only ๐‘—<๐‘˜ assignments - all those ๐‘— are valid assignments. If there are ๐‘—>๐‘˜ assignments with equal extremum - all those ๐‘— are valid assignments.

M1 location:

Q67: The three people with the largest number of parents

V1

Q68: The two dragons that were frozen by the largest number of dragons

V1

Q69: The two entities that own the largest number of entities

V1

Q70: The five people who the number of people with a path of length up to four from each of them - is the smallest

V1

Q196: Any dragon owned by Brandon Stark and the three dragons it froze that froze the largest number of dragons

V1

Q197: Any person A and Aโ€™s three dragons that the dragons they froze - froze the largest number of distinct dragons cumulatively

V1

Q234: Any person and the three dragons whose dragons froze - that froze the largest number of dragons

V1

Q236: Any person A and the three dragons whose dragons froze - that were frozen by the largest number of Aโ€™s dragons

V1

Q227: Any dragon owned by Brandon Stark, and the three dragons it froze or fired at - that froze the largest number of dragons

V1

Q238: For any pair of people (A, D) where Aโ€™s dragons froze Dโ€™s dragons - Aโ€™s three dragons that froze the largest number of Dโ€™s dragons

V1

Q299: For any pair of people (A, E) where at least one of Aโ€™s dragons froze at least one of Eโ€™s dragons - Aโ€™s (up to) three dragons that cumulatively froze the largest number of Eโ€™s dragons (two versions)

V1

Note that the same graph-entity may be assigned to B, C, and D.

V1

M2 Aggregator

V1

Let ๐ต denote a Cartesian product of one or more entity-tags. ๐ต must be nonempty and must not be composed of entity-tags composing ๐‘‡.

The lower part of an M2 aggregator contains the following elements:

For each ๐‘›: from the set of assignments in S(n) - [all but] the ๐‘˜ assignments BA(n)[k] with the minimal/maximal positive card(RC(n, o)) are reported.

If there are only j<k assignments - all those ๐‘— are valid assignments. If there are j>k assignments with equal extremum - all those ๐‘— are valid assignments.

M2 location:

Q78: The four dragons that froze Balerion the largest number of times

V1

Q171: The two dragons that were frozen the largest number of times

V1

Q172: The five people with the smallest positive number of paths of length up to four to some person

V1

(Compare with Q324)

Q77: The five pairs of dragons (A, B) with the largest number of times B froze A

V1

Q80: The three pairs of people with the largest number of paths of length up to four between them

V1

Q195: Any dragon owned by Brandon Stark and the three dragons it froze the largest number of times

V1

Q231: Any person A and the three dragons that were frozen by dragons that were frozen the largest number of times by Aโ€™s dragons

V1

Q228: Any dragon owned by Brandon Stark that fired at at least two dragons, and the three dragons it fired the largest number of times

V1

(counting the number of relationships assignments directly right of the quantifier)

Q237: For any pair of (A - a dragons owner, and C - a dragon that was frozen by Aโ€™s dragons) - the three dragons owned by A that froze C the largest number of times

V1

Q239: For any pair of people (A, D) where Aโ€™s dragons froze Dโ€™s dragons - the three pairs of (Aโ€™s dragon B, Dโ€™s dragon C) where B froze C the largest number of times

V1

M3 Aggregator

V1

Let ๐ต denote a Cartesian product of one or more entity-tags.

The lower part of an M3 aggregator contains the following elements:

For each ๐‘›: from the set of assignments in S(n) - [all but] the ๐‘˜ assignments BA(n)[k] with the minimal/maximal RA(n, k) are reported.

If there are only j<k assignments - all those ๐‘— are valid assignments. If there are j>k assignments with equal extremum - all those ๐‘— are valid assignments.

M3 location:

Q130: The four oldest people

V1

Q131: The four oldest males

V1

Q118: Any person A and Aโ€™s three oldest offspring

V1

Q119: Any person A and Aโ€™s three youngest sons

V1

Q74: Any person A and Aโ€™s three horses with the minimal first ownership start date

V1

Q230: Any person A and the three people A is a friend of or a friend of an offspring of - that own the heaviest horses

V1

Q232: Any person A and the three heaviest horses owned by people A is a friend of or a friend of an offspring of

V1

R1 Aggregator

V1

Let ๐‘… denote the relationship R1 appears below it.

The lower part of an R1 aggregator contains the following elements:

For each ๐‘›: from the set of assignments in S(n) - [all but] the ๐‘˜ assignments RA(n)[k] with the minimal/maximal relExpr are reported.

If there are only j<k assignments - all those ๐‘— are valid assignments. If there are j>k assignments with equal extremum - all those ๐‘— are valid assignments.

R1 location:

Q241: The four longest freezes

V1

Q161: For each dragon that froze at least one dragon at least once: the four longest freezes

V1

Q160: For each pair of dragons (A, B) where A froze B at least once: The four longest freezes

V1

Q240: For any pair of people (A, D): The four longest freezes where any of Aโ€™s dragons froze any of Dโ€™s dragons

V1

Aggregator Chains

Relationshipsโ€™ expressions and aggregators can be chained. When chained, each relationshipโ€™s expression and each aggregator with a constraint is a filtering stage. An assignment is valid only if all the chained constraints are satisfied, or in other words - if it passed all filtering stages.

Within a chain, relationshipsโ€™ expressions may not appear below aggregators. Also, an aggregator may not appear in a horizontal quantifierโ€™s branch. It may appear below a horizontal combiner that combines all the branches (see Q302, Q303).

Q96: Any dragon Balerion froze more than ten times - each on or after January 1, 1010, and for a duration shorter than ten minutes

V1

Note that the order of the constraints along the chain matters: the top two constraints filter relationships based on their propertiesโ€™ value. The third constraint is on the number of relationships that passed these filters.

Q302: Any dragon A that froze at least three dragons - each at least one time where at least two of the following conditions are satisfied: (i) the freeze duration was longer than ten minutes (ii) the freeze started after January 1, 980 (iii) the freeze ended before February 1, 980

V1

See Q185 for a different pattern structure that could be used.

Q303: Any pair of dragons (A, B) where A froze B at least three times, each for more than ten minutes, and either the freeze started after January 1, 980 or ended before February 1, 980

V1

Q186: Any dragon Balerion froze more than ten times for less than ten minutes, and at least once for ten minutes or more

V1

Q99: Any dragon Balerion froze more than ten times for less than ten minutes, and not once for ten minutes or more (two versions)

V1

V1

Q94: Any dragon that froze more than three dragons: each more than five times for more than ten minutes

V1

Filtering stages:

Q93: Any dragon A that froze more than three dragons - each at least five times for more than ten minutes

V1

(Similar to Q94, but the order of the aggregators is switched.) Filtering stages:

A dragon A that froze more than three dragons, each at least once for more than ten minutes, but froze only a single dragon more than five times for more than ten minutes - is a valid assignment in Q93 but not in Q94.

Q272: Any pair of dragons (A, B) where the longest freeze duration is at least ten times longer than the shortest freeze duration

V1

Q363: Any dragon that the latest time it froze some dragon for the first time was in or after 1010

V1

Q91: The four dragons with the maximal (shortest duration they were frozen for)

V1

Q90: The four pairs of dragons (A, B) where A froze B for the maximal cumulative duration

V1

Q92: The four dragons with the maximal (average duration they froze dragons for)

V1

Q201: For each dragon that froze at least ten dragons: the three dragons it froze for the maximal cumulative duration

V1

Q274: The four dragons with the largest difference between (the longest duration they froze dragon for) and (the shortest duration they froze dragon for)

V1

Q182: Any dragon owned by Brandon Stark and the three dragons it froze for the maximal cumulative duration

V1

Q133: The four people that the average weight of their horses is maximal

V1

Q132: The four people who own horses of the largest number of colors

V1

Q233: Any dragon A than froze dragons Bs that froze dragons Cs, and the three Cs for which A froze Bs for the maximal cumulative duration

V1

Q138: The four people who the people each of them is a friend of - cumulatively own horses of the largest number of colors

V1

Q183: The three dragons that dragons owned by Brandon Stark froze for the maximal cumulative duration

V1

Q168: The three people who the number of types of entities each of them owns is the largest

V1

Q163: Any dragon that the average duration of the ten shortest times it froze dragons is longer than 60 minutes

V1

Q162: Any pair of dragons (A, B) where the second shortest duration A froze B is longer than 60 minutes

V1

Q341: For each pair of dragons (A, B): the two shortest freezes A froze B. If there are more than two freezes with equal minimal duration - the two earliest amongst them

V1

Q268: Any pair of dragons (A, B) where the average duration of the 11th-20th most prolonged freezes A froze B is longer than 60 minutes (two versions)

V1

Q120: Any person A whose three oldest offspringโ€™s cumulative height is lower than Aโ€™s height

V1

Q202: Any person A whose three oldest offspringโ€™s average height is lower than the average height of all Aโ€™s offspring

V1

Q208: Any person whose three oldest horse-owning sons cumulatively own horses of three colors

V1

Q140: Any person whose three oldest sons cumulatively own horses of three colors

V1

Note that {3} is defined right of an โ€˜Oโ€™ and is evaluated to null when the optional part has no valid assignment. distinct does not aggregate null evaluation results.

Q141: Any person A whose three oldest sons cumulatively own horses of the same number of colors as of those cumulatively owned by Aโ€™s three youngest daughters

V1

Q95: Any dragon Balerion froze more than five times, each for more than ten minutes, and the total duration of those freezes was longer than 100 minutes (three versions)

V1

The two per pair constraints could be chained instead. The meaning would be similar:

V1

V1

Q199: Any dragon that (froze more than ten times each of more than ten dragons) and (froze more than 20 times each of less than ten dragons)

V1

Q200: Any dragon that (froze more than ten times each of more than ten dragons. For each of these ten dragons - the freezes had exactly two distinct durations) and (froze more than 20 times each of less than ten dragons. The average freeze duration of all these dragons - is longer than three minutes)

V1

Q277: Any dragon that the longest (cumulative duration it froze some dragon) is more than ten times longer than the shortest (cumulative duration it froze some dragon)

V1

Q351: Any person who owns two horses of different colors, a dragon that froze at least ten dragons of the same color as the first horse, and a dragon that froze at least ten dragons of the same color as the second horse

V1

Q320: Any person A where there are more horses of the same colors as Aโ€™s owned horses than dragons of the same colors as Aโ€™s owned dragons (version 1)

V1

The number of assignments to E is zero when the optional part has no assignment. We cannot simply test if E < {5} since if there are zero assignments to E per A - the constraint is not satisfied.

Q321: Any person A where more horses than dragons have the same name-length as a horse/dragon A owns (version 1)

V1

The number of assignments to D is zero when the optional part has no assignment. We cannot simply test if D < {4} since if there are zero assignments to D per A - the constraint is not satisfied.

Q259: Any person who since 1011 become an owner of no horses or up to four horses (two versions)

V1

V1

Q337: For each pair of dragons: each time one of them froze the other for a duration longer than the average duration of all the freezes that are longer than the average duration one of them froze the other

V1

Q317: Any dragon that the time difference between the earliest time it froze/fired at some dragon and the latest time it froze/fired at some dragon - is at least one year

V1

{1}, {2}, {3} and {4} are defined right of an โ€˜Oโ€™, hence evaluated to null when the optional part has no assignments. Since min({โ€ฆ}) and max({โ€ฆ}) ignore nulls, the pattern would yield the expected results even when dragon A froze no dragon or when dragon A fired at no dragon.

Q377: Any dragon and the three earliest times it froze/fired at some dragon

V1

{1} and {2} are defined right of an โ€˜Oโ€™, hence evaluated to [] when the optional part has no assignments.

Aggregator Sequences

Multiple aggregators may appear along a sequence. Along a sequence, aggregatorโ€™s constraints are evaluated from right to left, except where a constraint depends on the evaluation result of a constraint on its left (see Q376).

Q128: Any person A and Aโ€™s three offspring who own horses of the largest number of colors

V1

Q198: Any person A and Aโ€™s three dragons that (for each of them: the four dragons it froze that froze the largest number of dragons) - froze the largest number of distinct dragons cumulatively

V1

Q328: The three people with the maximal cumulative horse ownership days

V1

Q179: Any pair of dragons (A, B) where A froze B for a cumulative duration longer than the cumulative duration B froze dragons (two versions)

V1

V1

Q103: Any dragon A that froze at least three dragons, each of which was frozen by at least four dragons other than A

V1

Q106: Any dragon A that froze dragons at least three times - each was frozen at least four times by dragons other than A

V1

Q164: Any dragon that the number of times dragons it froze have frozen dragons (cumulatively) - is equal to the number of times dragons it fired at have fired at dragons (cumulatively)

V1

Q356: The average number of horse ownerships per person

V1

Q324: The five people with the smallest number (including zero) of paths of length up to four to some person

V1

(Compare with Q172)

Q107: Any dragon that (the number of dragons, each owned by five people, that froze it) is five, and that the number of times it was frozen by those dragons (cumulatively) is not five

V1

Q169: Any person A who (has at least one offspring who owns at least three horses) and (each of Aโ€™s offspring who owns at least three horses - owns horses of at least three colors)

V1

Q129: Any person A that (each of Aโ€™s offspring who owns at least one horse - owns a different number of horses)

V1

Q181: Any dragon with no intersection between the groups of dragons frozen by any two dragons it froze

V1

Q213: Out of the pairs of dragons (A, B) where A froze B for a cumulative duration longer than the cumulative duration B froze dragons - the five pairs with the largest number of times A froze B

V1

When the order of the aggregators along the chain is switched, the meaning changes:

Q376: Out of the five pairs of dragons (A, B) with the largest number of times A froze B โ€“ the pairs where A froze B for a cumulative duration longer than the cumulative duration B froze dragons

V1

Since {2} has a constraint that depends on the evaluation of {1}, {1} must be evaluated first. However, the M2 aggregator filters (A, B) pairs before {1} is evaluated.

Q191: Any dragon that froze dragons S and fired at dragons T. |S|โ‰ฅ3, |T|โ‰ฅ3 and |SโˆชT|โ‰ฅ10

V1

Q192: Any dragon that froze dragon mโ‰ฅ3 times and fired at dragons nโ‰ฅ3 times. m+nโ‰ฅ10

V1

Q193: Any dragon that froze dragons S, fired at dragons T, and fired โ‰ฅ3 times. |S|โ‰ฅ3 and |SโˆชT|โ‰ฅ10

V1

Q194: Any dragon that froze dragons m times, fired at dragons nโ‰ฅ3 times, and froze โ‰ฅ3 dragons. m+nโ‰ฅ10

V1

Q97: Any dragon that froze more than three dragons - each more than ten times or for a cumulative duration of more than 100 minutes

V1

Q180: Any pair of dragons (A, B) where the cumulative duration A and B froze each other - is longer than both the cumulative duration A froze other dragons and the cumulative duration B froze other dragons

V1

Q347: The five dragon triplets with the largest number of times triplet-members froze one another

V1

Note that we need to count each triplet only once (ignoring permutations).

Q100: Any dragon Balerion froze more than ten times for less than ten minutes, more than ten times on or after January 1, 1010, more than 15 times for less than ten minutes or on or after January 1, 1010, and more than 100 times altogether

V1

Extended Aggregators

V1

For extended aggregators, ๐‘‡ denotes an extended Cartesian product - a Cartesian product not just of entity-tags but of

Hence, for all extended aggregator types (A1, A2, A3, M1, M2, M3, and R1), the per clause has the following format:

Wherever possible, the notations โ€˜โ†โ€™, โ€˜โ†’โ€™ and โ€˜โŸทโ€™ are used instead of entity-tags.

For all extended M aggregators (M1, M2, and M3), the same is true also for ๐ต.

Here are two examples:

First example: Any person who at a certain date became an owner of more than five horses (Q115v2)

V1

{1} is evaluated per each unique assignment to A ร— df.since in ๐‘†. In other words, {1} is a property of each unique assignment to A ร— df.since in ๐‘†.

Second example: For each color of dragons that Balerion froze - the three dragons it froze the largest number of times (Q215)

V1

Extended A1 Aggregator

V1

Q261: Any color of which there are at least ten horses

V1

{2} is a property of each unique assignment to {1} in ๐‘†.

Q115: Any person who at a certain date became an owner of more than five horses (two versions)

V1

V1

{1} is a property of each unique assignment to A ร— df.since in ๐‘†.

Q289: Any person who at a certain three-day interval became an owner of more than five horses

V1

When ๐‘› intervals overlap, the intersection contains the start-time of at least one of the intervals (it also contains the end-time of at least one of the intervals).

Q283: Any person who at a certain day owned at least five horses

V1

Q284: Any person who owned the same five horses - for at least ten consecutive days (version 1)

V1

Q378: Any relationship-type that holds between more than 1000 pairs of dragons

V1

Q217: Any dragon and the dragons it froze - on days it froze between one and five dragons

V1

Q114: Any person who owns at least five horses of the same color (version 3)

V1

Q218: Any person who owns at least five entities of the same type (version 2)

V1

Q157: Any person who owns between one and three horses of the same color - for at least six colors

V1

Q214: Any person who owns entities of at least four types. For each type - at least five entities

V1

Q235: Any dragon that the number of dragons it froze on average - on months it froze dragons in - is at least ten

V1

Q153: Any dragon A that in each of at least 11 days - froze between one and five dragons

V1

Q252: Any dragon B that in each of at least 11 days - was frozen by a dragon that on that day froze between one and five dragons

V1

Q255: Any dragon whose name-length is equal to the number of days in each of which it froze ten dragons

V1

Q278: Any pair of dragons (A, B) that in each of at least 11 days - A froze between one and five dragons, one of them is B

V1

Q254: Any dragon that in each year it froze dragons - it froze more than three dragons

V1

Q306: The three dragons that the number of days in each of which each froze at least five dragons - is maximal

V1

Q285: Any person who at a certain day owned at least five horses and at least five dragons

V1

Q286: Any person who at each day of at least ten (not necessarily consecutive) days - owned at least five horses (not necessarily the same horses each day)

V1

Q158: Any dragon that in each of at least ten days - the number of dragons it froze is greater than the number of dragons that froze it

V1

Note the location of {6}. If it was below {1}, the evaluation order was different. As it is, {6} counts distinct assignments to {1} for which the All quantifier was satisfied.

Q260: Any dragon that in each of at least ten days: (i) the number of dragons it froze is greater than the number of dragons that froze it, and (ii) it froze/was frozen at least five times

V1

Q350: Any pair of people who own the same number of entities of each type

V1

Q332: Any person whose horses are all of rare colors. A rare color is a color of less than 1% of the horses (two versions)

V1

V1

Q338: Any person who owns at least ten horses, at least half of which are of rare colors. A rare color is a color of less than 1% of the horses (two versions)

V1

V1

Extended A2 Aggregator

V1

Q330: Any day during which more than five horse-ownerships started

V1

Q270: Any person A and Aโ€™s horses of the colors for which there are more than five horse-ownerships by a person

V1

Extended A3 Aggregator

V1

Q331: Any day at which the horse ownerships that started (and ended since) lasted on average for at least ten years

V1

Q271: Any person A and Aโ€™s horses of the colors for which the average ownership start date is at least January 1, 1010

V1

Q263: Any horse of each color of which the average horsesโ€™ weight is greater than 450 Kg

V1

Q265: Any horse of each color of which the average horsesโ€™ ownersโ€™ height is at least 180 cm

V1

Q155: Any dragon that in each of at least 11 days - froze dragons for more than 100 minutes cumulatively

V1

Q156: Any dragon that froze dragon for more than 1000 minutes cumulatively - in the days it froze dragons for more than 100 minutes

V1

Q154: Any dragon that in each of at least four years - in each of at least 11 days - froze between one and five dragons

V1

Q159: Any dragon for which there are more days where (it froze/was frozen at least five times, and the number of dragons it froze is greater than the number of dragons that froze it) than days where (it froze/was frozen at least five times, and the number of dragons that froze it is greater than the number of dragons it froze)

V1

(Compare with Q260)

Q361: Any person A who owns horses of at least five colors, and the sets of weights of Aโ€™s horses of each of these colors are identical

V1

Q320: Any person A where there are more horses of the same colors as Aโ€™s owned horses than dragons of the same colors as Aโ€™s owned dragons (version 2)

V1

Q321: Any person A where more horses than dragons have the same name-length as a horse/dragon A owns (version 2)

V1

Extended M1 Aggregator

V1

Q220: Any person A and Aโ€™s horses of the three colors of which A owns the largest number of horses

V1

Q262: Any horse of the three most common horse colors

V1

Q224: Any person A and Aโ€™s horses of the three colors with the smallest positive number of horse owners (two versions)

V1

V1

Q342: The three colors for which the number of pairs of dragons of that color where at least one of them froze the other - is maximal (version 1)

Note that if a pair of dragons mutually froze each other - we need to count this pair only once.

V1

Q343: The three color-pairs (1, 2) for which the number of dragon pairs where a dragon of color 1 froze a dragon of color 2 is maximal

V1

Q251: The three pairs (person, color) with most horses of this color owned by that person

V1

Q211: For each total number of freezes by a dragon: the three dragons that froze the largest number of dragons

V1

Q212: The three most common total number of freezes by a dragon

V1

Q325: For each of the three most common horse colors: the three people who own the largest number of horses of this color

V1

Q326: For the three most common horse colors (combined): the three people who own the largest number of horses of these colors

V1

Extended M2 Aggregator

V1

Q215: For each color of dragons that Balerion froze - the three dragons it froze the largest number of times

V1

Q221: Balerion and the dragons it froze - of the three colors it froze dragons the largest number of times

V1

Q280: Any dragon and the dragons it froze - of the three colors it froze dragons the largest number of times

V1

Q253: For each number of dragonโ€™s owners - the three dragons Balerion froze the largest number of times

V1

Q225: Any person A and Aโ€™s horses of the three colors with the smallest positive number of horse ownerships by a person

V1

Q281: Any dragon and the dragons it froze - of the three colors of which dragons were frozen the largest number of times

V1

Q319: Any dragon and the dragons it froze - of the 4th-6th colors of which dragons were frozen the largest number of times (two versions)

V1

V1

Q282: Balerion and the dragons it froze - of the three colors of which dragons were frozen the largest number of times

V1

Q209: The three most owned entity-types

V1

Q210: The three pairs (owner entity-type, owned entity-type) with most _owns relationships_

V1

Q369: The three most common relationship-types and the number of relationships of each of these types

V1

Q370: The most common relationship-type between entities of the same type

V1

Extended M3 Aggregator

V1

Q275: Any person A and Aโ€™s horses of the three colors of which A owns the heaviest horse

V1

Even if Aโ€™s three heaviest horses are of the same color, we would still get all Aโ€™s horses for two more colors (those with the next heaviest horses)

Q223: Any person A and Aโ€™s horses of the three colors for which the cumulative weight of Aโ€™s horses is maximal

V1

Q222: Any person A and Aโ€™s horses of the three colors for which Aโ€™s average ownership start date is the latest

V1

Q269: Any person A and Aโ€™s horses of the three colors for which the average ownership start date is the latest

V1

Q276: Any person A and Aโ€™s horses of the three colors for which the earliest horse ownership start date is the earliest

V1

Even if the three horses with the earliest ownership start date are of the same color, we would still get all people and their horses of two more colors (of the next-earliest ownership start dates)

Q216: Any dragon Balerion froze during the three 30-day timeframes during which it froze dragons the largest number of times

V1

Q373: The three 30-day timeframes during which dragons were frozen the largest number of times

V1

Q374: The three most prolonged timeframes during which no dragon was frozen

V1

Q264: Any horse of the three colors of which the average horsesโ€™ weight is maximal

V1

Q226: Any person A and Aโ€™s horses - of the three horse-colors for which the average height of the horse owners is minimal

V1

Q342: The three colors for which the number of pairs of dragons of that color where at least one of them froze the other - is maximal (versions 2, 3)

Note that if a pair of dragons mutually froze each other - we need to count this pair only once.

V1

V1

Extended R1 Aggregator

V1

Q273: For each horse color - the three horse-ownerships with the latest ownership start date

V1

Multivalued Functions and Expressions

A multivalued function is a function that may associate zero or more values to each input. In V1, expressions composed of multivalued functions are evaluated separately for each output associated with the input.

V1 supports the following multivalued functions:

All these multivalued functions have no associations when the input is an empty set or bag.

In the following examples, Person has the following property: nicknames: set(string).

Q379: Any person who has at least one nickname

V1

Even though {1} has no explicit constraints, it must have at least one assignment.

Q307: Any person who has a nickname containing an โ€˜aโ€™

V1

{1} is a multivalued expression. For each person, {1} is evaluated for each nickname. If at least one nickname satisfies the constraint - this person is a valid assignment.

Q316: Any pair of people with a common nickname

V1

{1} is evaluated for each non-null nickname of A. {2} is evaluated for each non-null nickname of B. All combinations are evaluated.

Q308: Any person who has a nickname containing both (an โ€˜aโ€™ or an โ€˜Aโ€™) and (a โ€˜bโ€™ or a โ€˜Bโ€™)

V1

For each person, {1} is evaluated for each non-null nickname. {2} and {3} are evaluated for each value of {1}. If {2} and {3} satisfies the constraints for at least one evaluation of {1} - the person is a valid assignment. A person with no non-null nicknames will not be evaluated.

Q309: Any person who has at least two nicknames (two versions)

V1

The count function returns the number of values a multivalued expression has. {1} is a single-valued expression.

An A3 aggregator can be used for aggregating the evaluations of a multivalued expression:

V1

{2} is assigned with the number of distinct non-null evaluations of {1}.

Q310: Any person who has at least two nicknames - each contains an โ€˜aโ€™ (two versions)

V1

V1

Q311: Any person who has at least five nicknames - each contains either an โ€˜aโ€™ or a โ€˜bโ€™

V1

Q312: Any person with more nicknames containing a โ€˜bโ€™ or a โ€˜Bโ€™ than nicknames containing an โ€˜aโ€™ or an โ€˜Aโ€™

V1

Note that if a nickname contains both an โ€˜aโ€™ and a โ€˜bโ€™ - it would be assigned to both {1} and {4}.

Q313: Any person A that has at least one nickname and all Aโ€™s nicknames contain an โ€˜aโ€™

V1

Q314: Any person who has at least one nickname, but none of its nicknames contain an โ€˜aโ€™

V1

Q315: Any person A that the average length of Aโ€™s three shortest nicknames is at least three

V1

Q348: Any person A that the combined weight of three, four or five of Aโ€™s horses - is exactly 1000 Kg

V1

Q349: Any person A that Aโ€™s horses can be split into three groups with an identical combined weight

V1

Relationships may have multivalued expressions as well.

Q284: Any person who owned the same five horses - for at least ten consecutive days (version 2)

V1

The set function returns a set of all individual dates within the tf dateframe. el is a single element of this set (a single date). Each value is evaluated separately.

Q340: Any person who owned the same five horses - in at least ten (not necessarily consecutive) days

V1

{2} and {5} are sets of all horse ownership dates, aggregated over all โ€˜ownsโ€™ relationships.

Expression-tag {3} represents one subset of set expression {2}. The constraint in {4} limits assignments to {3} to subsets of {2} with exactly ten elements. {2}, {3} and {4} are properties of A ร— B.

Q287: Any person who at each day of at least ten (not necessarily consecutive) days - owned the same two horses

V1

Q327: Any person who at each day of at least ten consecutive days - owned at least five horses (not necessarily the same horses each day)

V1

Q318: Any dragon Balerion froze/fired at during the three 30-day timeframes during which it froze/fired at dragons the largest number of times

V1

Note that {1} and {2} are defined right of an โ€˜Oโ€™, hence evaluated to empty sets when the optional parts have no assignments. Since ๐‘† โˆช โˆ… = ๐‘†, the pattern is valid even if Balerion froze no dragon or if it fired at no dragon.

{3} is a property of A, but, being an aggregated multivalued expression, must be defined right of the aggregator.

Q371: Any dragon Balerion froze/fired at during the three non-overlapping 30-day timeframes during which it froze/fired at dragons the largest number of times

V1

{1}, {2} and {3} are sets of intervals of datetimeframe. In {5}, {3} is coerced to set of datetimeframes. {4} and {5} limit assignment to {3} to sets with three non-overlapping members.

{6} is a multivalued expression evaluated per each value of the multivalued expression {3}. The M2 aggregator is evaluated for all assignments to {6} of each assignment to {3}.

Application: Spatiotemporality

Dragon-spotting is a major hobby around the world. Dragon-spotters document the time, location, and of course - the identity of the dragon they spotted. The location may be a point (longitude and latitude) or a small area - when they are not sure about the exact coordinates. Most observations are attributed to the spotter, but in many ancient documents - the dragon-spotter is unknown.

We will extend our sample schema with the following relationship-type:

spotted is a relationship between a dragon-spotter (which may be unknown) and the dragon spotted. The properties of the relationship are the time and the location where the dragon was spotted.

location is an opaque data type (see above) that contains a geographic point (e.g., latitude and longitude) or a geographic shape (a circle, an ellipse, a polygon, etc.)

Functions over location expressions:

Constraint operators over location expressions:

Two entity-types are defined as well:

Note that we chose to hold the location of stationary entities (landmark, city) as entity properties, and hold the location of mobile entities (dragon) as relationship properties.

G1: Any dragon observed at Dragonmont Peak

V1

G2: Any dragon observed within 5 Km from Dragonmont Peak

V1

G3: Any dragon observed within 5 Km from Dragonmont Peak at least five times during a 7-day period

V1

G4: Any dragon observed within 5 Km from Dragonmont Peak between 4 AM and 7 AM in at least five days during a 7-day period

V1

G5: Any dragon observed within 5 Km from Dragonmont Peak in at least five separate weeks

V1

G6: Any week during which at least five dragons were observed within 5 Km from Dragonmont Peak

V1

G7: Any dragon with conflicting observations (given that dragons cannot fly faster than 300 Km/h)

V1

G8: Any Sarnorian B for whom at least three of Bโ€™s dragons were spotted within 5 Km from Dragonmont Peak - in a timeframe of 24 hours

V1

G9: Any dragon that stayed within 5 Km from Dragonmont Peak for at least one week (To ensure this - the dragon should have been spotted there at least once per 6 hours and not spotted at any other location throughout that period)

V1

G10: Any pair of dragons that were spotted within 5 Km from each other at least five observation-pairs (To ensure this - paired observation should differ in up to 5 minutes; observation pairs should differ in at least 24 hours)

V1

G11: Any pair of dragons A and B, where at least ten times in the last 300 days A was spotted at a distance of less than 1 Km from places where B was spotted between one day and five days before

V1

G12: Any pair of dragons that were spotted within 5 Km from each other at least 5 observation-pairs during a 30-day period (To ensure this - paired observation should differ in up to 5 minutes; observation pairs should differ in at least 24 hours)

V1

G13: Any Sarnorian E whose dragons seem to โ€œspyโ€ on Balerion (at least one of Eโ€™s dragons was spotted at most 1 Km from Balerion throughout a ten-day period. Paired observation should differ in up to 5 minutes; observation pairs should differ in no more than 1 hour)

V1

G14: Any pair of dragons that were spotted not less than 1000 Km from each other throughout a period of at least one year (To ensure this - paired observation should differ in up to 30 minutes; observation pairs should differ in no more than 24 hours)

V1

G15: Any landmark where at least five dragons were spotted within 5 Km from it

V1

G16: Any city in which at least five dragons were spotted throughout a 2-minutes period

V1

G17: Any landmark where at least five dragons were spotted within 5 Km from it throughout a 7-day period

V1

G18: Any dragon spotted in at least ten cities

V1

G19: Any dragon spotted in at least ten cities throughout a ten-day period

V1

G20: Any dragon that traveled at least 2000 Km in a 24-hours period

V1

G21: Any dragon-spotter that spotted the same dragon at two locations - at least 1000 Km apart

V1