New ACM paper, free-tier cloud, and open-source license

Keywords

The source of truth for the TypeQL keywords and grammar is the ANTLR v.4 specification file: TypeQL.g4.

Clauses

Clause keywords declare a start of a query’s clause:

define

Starts a define clause of a Define query.

undefine

Starts an undefine clause of a Undefine query

match

Starts a match clause that matches existing data by a pattern in an Insert, Delete, Update, Fetch, or Get query.

insert

Starts an insert clause of an Insert query.

delete

Starts a delete clause of a Delete query.

fetch

Starts a fetch clause of a Fetch query.

get

Starts a get clause of a Get query.

Schema statements

Schema statement keywords used inside a clause of a query as a part of a data pattern or a schema definition:

sub

Adds a constraint on a type to be any subtype of a given type.
For more information, see the sub / sub! page.

sub!

Adds a constraint on a type to be a direct subtype of a given type.
For more information, see the sub / sub! page.

type

Adds a constraint on a type to be an exact type by its label.
For more information, see the type page.

abstract

Specify that a given type is an abstract type.
For more information, see the abstract page.

owns

Specify that a type can own attributes of a given attribute type.
For more information, see the owns page.

value

Specify a value type of an attribute type.
For more information, see the value page.

relates

Add a new role for a relation.
For more information, see the relates page.

plays

Specify that a given type can play a given role (in a given relation).
For more information, see the plays page.

@key

Add a key constraint to ownership of a given attribute type by a type.
For more information, see the @key page.

@unique

Add a uniqueness constraint to ownership of a given attribute type by a type.
For more information, see the @unique page.

regex

Specify a regular expression that limits values of a given attribute type.
For more information, see the regex page.

as

Override an inherited attribute type ownership or role playing ability.
For more information, see the owns and plays pages respectively.

when

Specify a condition of a rule.

then

Specify a conclusion of a rule.

Data statements

Data statement keywords used inside a clause of a data query as a part of a data pattern:

isa

Adds a constraint for a data instance to be an instance of a type. Takes into account type inference.
For more information, see the isa / isa! page.

isa!

Adds a constraint for a data instance to be an instance of a type. Does not take into account type inference.
For more information, see the isa / isa! page.

is

Adds a constraint for two concept variables to be equal both by value and type.
For more information, see the isa / isa! page.

has

Adds a constraint for an ownership of a given attribute by a given data instance.
For more information, see the has page.

Modifiers

offset

Offset the result of a query by the specified number of results.
See an example.

limit

Limit the result of a query by the specified number of results.
See an example.

sort

Sort the results of a query.
See an example.

Logic

or

Specify a disjunction between two blocks of statements surrounded by curly brackets.
For more information, see the OR (Disjunction) page.

not

Specify a negation of a block of statements surrounded by curly brackets.
For more information, see the NOT (Negation) page.

Value comparators

==, !=, >, <, >=, <=, like, contains

Specify the result of comparison to be true.
For more information, see the Comparators page.

Aggregation

group

Group results by a given variable.
For more information, see the Grouping page.

count

Count the number of results.
For more information, see the Aggregation page.

max

Find the maximum value of a given variable.
For more information, see the Aggregation page.

min

Find the minimum value of a given variable.
For more information, see the Aggregation page.

mean

Find average value of a given variable.
For more information, see the Aggregation page.

median

Find median value of a given variable.
For more information, see the Aggregation page.

std

Find standard deviation of values for a given variable.
For more information, see the Aggregation page.

sum

Find the sum of values for a given variable.
For more information, see the Aggregation page.

Provide Feedback