Officially out now: The TypeDB 3.0 Roadmap >>

Patterns

This reference covers the usage of patterns in TypeQL.

Scopes and operations

Pattern comprise statements containing variables. Given a pattern, the scope of a variable is:

  • the block { …​ } in which variable appears at top-level (i.e., not nested in further {…​}) but it does not appear outside of the block,

  • or, the entire pattern itself if the variable appears at the top-level of the pattern itself.

A key principle of valid TypeQL pattern is:

Every variable must have a unique scope.

While a statement by itself is an (elementary) patterns, operations allow us to construct larger and more interesting patterns from smaller ones, and they create new scopes of variables.

Operation reference

Use of conjunctions to join patterns into a single query pattern that combines all given constraints.

Use of disjunctions to allow for several branches in a query to be executed in parallel.

Use of negations to exclude patterns from your query results.