MATCH, CREATE, property filters, metaqueries, and available data types.
Basics
Queries are built by referencing nodes and edges. TuringDB supports the standard CYPHER syntax, in that nodes are denoted using parentheses(), whilst edges are denoted using square brackets [].
For example, (n) would denote a node named n, whilst [e] would denote an edge named e.
Nodes and edges can have both label and property constraints. As in standard CYPHER, property constraints are specified using curly brackets {}, whilst labels are specified using colon : syntax.
An example of a node with a label constraint would be (n:Person).
An example of an edge with a property constraint would be [e {duration: 10}].
Property and label constraints may be combined, for instance, (n:Person {name: 'John'}) specifies a node which both has the label Person, and a name property with the value John.
Nodes and edges can have label and property multiple constraints, which are specified in a comma-separated list: (n:Person:Man {name: 'John', age: 20}). These lists can be arbitrarily long.
Summary:
Queries are built around nodes and edges:- Nodes are written in parentheses
()e.g.(n)- a node with aliasn - Edges are written in square brackets
[]e.g.[e]- an edge with aliase
- Labels with a colon
:- e.g.(n:Person) - Property constraints with curly braces
{}- e.g.[e {duration: 10}] - Both at once - e.g.
(n:Person {name: 'John'})
Queries
Queries are built up of combinations of nodes and edges, as specified above. TuringDB supports two main query operations:MATCH and CREATE.
MATCH queries
MATCH queries are used to retrieve nodes, edges, and their property values from the database via specification of relationships and properties.
It is easiest to demonstrate the syntax of a MATCH query with a concrete example:
n.
MATCH queries are flexible: they can contain a single node and no edges, or any number of node, edge pairs. For example:
MATCH query would be:
Queries have variables, which in the above examples are those such as Both node and edges can omit a variable name if they specify at least a label constraint:
n, m, e, etc. Variables are a way to give a name to a node or an edge, so that those nodes or edges can be specified in the RETURN clause. However, if you do not want to return an edge or its properties, the edge need not have a name. For example:MATCH queries, and the ability to specify constraints, here are a few examples of some syntactically correct TuringDB MATCH queries:
MATCH (n:Person) RETURN n.nameMATCH (:Person)-->(n:Person) RETURN n.nameMATCH (n:Person:Woman:SoftwareEngineer) RETURN n.nameMATCH (n:Person:Woman:SoftwareEngineer)-->(m)-[e]->(p:Man)-[f]->(q) RETURN e, f
CREATE queries
CREATE queries follow exactly the same syntax as MATCH queries when it comes to specifying nodes, edges, and property/label constraints, but they do not have RETURN clauses. There is also the additional requirement that all nodes and edges must have at least one label. This means a query such as
CREATE queries have no RETURN clause, there is no requirement to declare any names for any variables. This means we can have queries such as
Data Types
TuringDB offers the following data types for node and edge properties:- String
- Boolean
- Integer (signed)
- Double (decimal)
"), single quotes ('), or backticks (```).
Operators
TuringDB requires you to query against node and edge properties using the: operator for exact matching of the property value.
~=, which is explained here.
Metaqueries
On top of supporting queries which return or alter information in the graph, TuringDB supports a number of “metaqueries” which return information, or metadata, about the graph. These queries follow theCALL syntax, and the following variants are supported:
CALL db.propertyTypes ()- returns a column of all the different node and edge properties and their types in the databaseCALL db.labels ()- returns a column of all the different node labelsCALL db.edgeTypes()- returns a column of all the different edge types (edge equivalent of node labels)CALL db.history ()- returns a dataframe containing commit history
MATCH queries.
Commands
Outside of CYPHER, there are a number of commands which you can use to interact with the TuringDB engine.| Command | Explanation |
|---|---|
CREATE GRAPH <graph name> | Create a graph with the specified name |
LOAD GRAPH <graph name> | Load the specified graph. Requires the graph files to be accessible to the TuringDB instance |
HISTORY | Prints the history of the version control system |
CHANGE NEW | Creates a new change, returning a column with the ID of the created change |
CHANGE SUBMIT | When checked out on a specific change, submits all changes made to the “master branch” |
CHANGE DELETE | Deletes the currently checked out change |
CHANGE LIST | Lists the currently active (uncommitted) changes |
LIST GRAPH | Lists the available graphs |

