schema

The schema module offers procedures that allow you to interact with and retrieve information about the database schema.

docs-source (opens in a new tab)

TraitValue
Module typeutil
ImplementationC++
Parallelismsequential

Procedures

node_type_properties()

This procedure returns schema information about nodes and their properties in the graph. For every property in a node, a separate row is created.

Output:

  • labels: List[string] ➡ list of labels of the node.
  • mandatory: boolean ➡ a boolean which is True if the node has properties, False if the node has no properties.
  • property_name: string ➡ name of the property.
  • property_type: string ➡ type of the property.

Usage:

Cypher for creation of graph used in example:

CREATE (d:Dog {name: "Rex", age: 5})-[l:LOVES {how_much: "very"}]->(h:Human:Owner {name: "Carl", age: 90});
CREATE (n:NonManadatoryNode);

Cypher usage of the procedure:

CALL schema.rel_type_properties() YIELD mandatory, property_name, property_type, rel_type RETURN mandatory, property_name, property_type, rel_type;
+-------------------------------------------------------------------+
| labels                | mandatory | property_name | property_type |
+-------------------------------------------------------------------+
| ["Dog"]               | true      | age           | Int           |
+-------------------------------------------------------------------+
| ["Dog"]               | true      | name          | String        |
+-------------------------------------------------------------------+
| ["Human", "Owner"]    | true      | age           | Int           |
+-------------------------------------------------------------------+
| ["Human", "Owner"]    | true      | name          | String        |
+-------------------------------------------------------------------+
| ["NonManadatoryNode"] | false     |               |               |
+-------------------------------------------------------------------+

rel_type_properties()

This procedure returns schema information about relationships and their properties in the graph. For every property in a relationship, a separate row is created.

Output:

  • rel_type: string ➡ the type of the relationship.
  • mandatory: boolean ➡ a boolean which is True if the node has properties, False if the node has no properties.
  • property_name: string ➡ name of the property.
  • property_type: string ➡ type of the property.

Usage:

Cypher for creation of graph used in example:

CREATE (d:Dog)-[r:RUNS_AND_PLAYS_IN {speed: 100, duration: "5 hours" }]->(p:Park);
CREATE (b:Bird)-[f:FLIES_TO]->(s:Sky);

Cypher usage of the procedure:

CALL schema.rel_type_properties() YIELD rel_type, mandatory, property_name, property_type RETURN rel_type, mandatory, property_name, property_type;
+-------------------------------------------------------------------+
| labels                | mandatory | property_name | property_type |
+-------------------------------------------------------------------+
| RUNS_AND_PLAYS_IN     | true      | duration      | String        |
+-------------------------------------------------------------------+
| RUNS_AND_PLAYS_IN     | true      | speed         | Int           |
+-------------------------------------------------------------------+
| FLIES_TO              | false     |               |               |
+-------------------------------------------------------------------+