Show graph typesCypher 25 onlyEnterprise EditionIntroduced in Neo4j 2026.02
The SHOW CURRENT GRAPH TYPE command allows you to show the graph type specification for the current database.
It can either be shown as a string representation or, as of Neo4j 2026.06, a virtual graph representation.
For general information about the SHOW command, see the SHOW page.
Showing a graph type requires the SHOW CONSTRAINTS privilege.
|
Examples
The graph type used for the examples are:
ALTER CURRENT GRAPH TYPE SET {
(p:Person => :Resident {name :: STRING, ssn :: INTEGER})
REQUIRE (p.name, p.ssn) IS KEY,
(:Pet => :Resident&Animal {insuranceNumber :: INTEGER IS KEY, healthCertificate :: STRING IS UNIQUE, name :: STRING}),
(:Robot => :Resident&Machine {application :: STRING NOT NULL, id :: INTEGER NOT NULL}),
(:City => {name :: STRING NOT NULL, population :: INTEGER}),
(:Resident)-[:LIVES_IN => {since :: ANY NOT NULL}]->(:City),
(:Company => {name :: STRING, address :: STRING IS UNIQUE}),
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company),
CONSTRAINT company_name FOR (c:Company) REQUIRE c.name IS KEY,
CONSTRAINT animal_id FOR (a:Animal) REQUIRE a.id IS UNIQUE,
CONSTRAINT resident_address FOR (resident:Resident) REQUIRE resident.address :: STRING,
CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE (r.startDate) IS NOT NULL,
CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE (r.startDate) IS :: DATE,
CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE (r.endDate) IS :: DATE
}
Show full graph type as a string
SHOW CURRENT GRAPH TYPE
+------------------------------------------------------------------------------------------------------------------------------+
| specification |
+------------------------------------------------------------------------------------------------------------------------------+
| "{ |
| (:`City` => {`name` :: STRING NOT NULL, `population` :: INTEGER}), |
| (:`Company` => {`address` :: STRING, `name` :: STRING}), |
| (:`Person` => :`Resident` {`name` :: STRING, `ssn` :: INTEGER}), |
| (:`Pet` => :`Animal`&`Resident` {`healthCertificate` :: STRING, `insuranceNumber` :: INTEGER, `name` :: STRING}), |
| (:`Robot` => :`Machine`&`Resident` {`application` :: STRING NOT NULL, `id` :: INTEGER NOT NULL}), |
| (:`Resident`)-[:`LIVES_IN` => {`since` :: ANY NOT NULL}]->(:`City` =>), |
| (:`Person` =>)-[:`WORKS_FOR` => {`role` :: STRING}]->(:`Company` =>), |
| CONSTRAINT `constraint_d7524c38` FOR (`n`:`Company` =>) REQUIRE (`n`.`address`) IS UNIQUE, |
| CONSTRAINT `company_name` FOR (`n`:`Company` =>) REQUIRE (`n`.`name`) IS KEY, |
| CONSTRAINT `constraint_bb1018eb` FOR (`n`:`Person` =>) REQUIRE (`n`.`name`, `n`.`ssn`) IS KEY, |
| CONSTRAINT `constraint_302a3693` FOR (`n`:`Pet` =>) REQUIRE (`n`.`healthCertificate`) IS UNIQUE, |
| CONSTRAINT `constraint_aa881a72` FOR (`n`:`Pet` =>) REQUIRE (`n`.`insuranceNumber`) IS KEY, |
| CONSTRAINT `animal_id` FOR (`n`:`Animal`) REQUIRE (`n`.`id`) IS UNIQUE, |
| CONSTRAINT `resident_address` FOR (`n`:`Resident`) REQUIRE (`n`.`address`) IS :: STRING, |
| CONSTRAINT `stayed_in_endDate` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`endDate`) IS :: DATE, |
| CONSTRAINT `stayed_in_startDateExistence` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`startDate`) IS NOT NULL, |
| CONSTRAINT `stayed_in_startDateType` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`startDate`) IS :: DATE |
| }" |
+------------------------------------------------------------------------------------------------------------------------------+
Regardless of which syntax was used to define a property uniqueness or key constraint, they are all shown in the specification returned by SHOW CURRENT GRAPH TYPE using the CONSTRAINT … FOR … REQUIRE syntax.
|
Show full graph type as a virtual graphIntroduced in Neo4j 2026.06
SHOW CURRENT GRAPH TYPE AS GRAPH
The following graph is returned:
The following table is returned:
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes | relationships |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [(:AnyLabel {}), (:NodeElementType {label: "City", properties: ["name :: STRING NOT NULL", | [[:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "LIVES_IN", |
| "population :: INTEGER"], constraints: []}), (:NodeElementType {label: "Company", | properties: ["since :: ANY NOT NULL"], constraints: []}], [:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "WORKS_FOR", properties: |
| properties: ["address :: STRING", "name :: STRING"], constraints: [ | ["role :: STRING"], constraints: []}], [:RELATIONSHIP_TYPE {relationshipType: "STAYED_IN", constraints: [ |
| "CONSTRAINT constraint_d7524c38 FOR (n:Company =>) REQUIRE n.address IS UNIQUE", | "CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE r.endDate IS :: DATE", |
| "CONSTRAINT company_name FOR (n:Company =>) REQUIRE n.name IS KEY"]}), (:NodeElementType | "CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS NOT NULL", |
| {label: "Person", properties: ["name :: STRING", "ssn :: INTEGER"], constraints: [ | "CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS :: DATE"]}]] |
| "CONSTRAINT constraint_bb1018eb FOR (n:Person =>) REQUIRE (n.name, n.ssn) IS KEY"]}), (:NodeElementType | |
| {label: "Pet", properties: ["healthCertificate :: STRING", "insuranceNumber :: INTEGER", "name :: STRING"], | |
| constraints: ["CONSTRAINT constraint_302a3693 FOR (n:Pet =>) REQUIRE n.healthCertificate IS UNIQUE", | |
| "CONSTRAINT constraint_aa881a72 FOR (n:Pet =>) REQUIRE n.insuranceNumber IS KEY"]}), (:NodeElementType | |
| {label: "Robot", properties: ["application :: STRING NOT NULL", "id :: INTEGER NOT NULL"], constraints: []}), | |
| (:NodeLabel {label: "Animal", constraints: ["CONSTRAINT animal_id FOR (n:Animal) REQUIRE n.id IS UNIQUE"]}), | |
| (:NodeLabel {label: "Machine", constraints: []}), (:NodeLabel {label: "Resident", constraints: [ | |
| "CONSTRAINT resident_address FOR (n:Resident) REQUIRE n.address IS :: STRING"]})] | |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
The nodes column contains a list of virtual nodes representing the node element types and node labels defined in the graph type.
The relationships column contains a list of virtual relationships representing the relationship element types, relationship constraints not belonging to any relationship element type, and label implications in node element types.
Four entities in the result are worth noting:
-
NodeElementType: a virtual node representing a node element type in the graph type. -
NodeLabel: a virtual node representing a node label in the graph type. -
AnyLabel: relationship element types with unconstrained endpoints are represented by a virtual any-node with the labelAnyLabeland no properties. Each relationship gets its ownAnyLabelnode. -
IMPLIES: when a node element type implies another label, the two are connected by a relationship of typeIMPLIESwith no properties.
For more information, see virtual nodes and virtual relationships below.
Together, the two lists returned in the nodes and relationships columns form the following graph:
(city:NodeElementType {label: "City", properties: ["name :: STRING NOT NULL", "population :: INTEGER"], constraints: []}),
(company:NodeElementType {label: "Company", properties: ["address :: STRING", "name :: STRING"], constraints: ["CONSTRAINT constraint_d7524c38 FOR (n:Company =>) REQUIRE n.address IS UNIQUE", "CONSTRAINT company_name FOR (n:Company =>) REQUIRE n.name IS KEY"]}),
(person:NodeElementType {label: "Person", properties: ["name :: STRING", "ssn :: INTEGER"], constraints: ["CONSTRAINT constraint_bb1018eb FOR (n:Person =>) REQUIRE (n.name, n.ssn) IS KEY"]}),
(pet:NodeElementType {label: "Pet", properties: ["healthCertificate :: STRING", "insuranceNumber :: INTEGER", "name :: STRING"], constraints: ["CONSTRAINT constraint_302a3693 FOR (n:Pet =>) REQUIRE n.healthCertificate IS UNIQUE", "CONSTRAINT constraint_aa881a72 FOR (n:Pet =>) REQUIRE n.insuranceNumber IS KEY"]}),
(robot:NodeElementType {label: "Robot", properties: ["application :: STRING NOT NULL", "id :: INTEGER NOT NULL"], constraints: []}),
(animal:NodeLabel {label: "Animal", constraints: ["CONSTRAINT animal_id FOR (n:Animal) REQUIRE n.id IS UNIQUE"]}),
(machine:NodeLabel {label: "Machine", constraints: []}),
(resident:NodeLabel {label: "Resident", constraints: ["CONSTRAINT resident_address FOR (n:Resident) REQUIRE n.address IS :: STRING"]}),
(any:AnyLabel {}),
(person)-[:IMPLIES {}]->(resident),
(pet)-[:IMPLIES {}]->(animal),
(pet)-[:IMPLIES {}]->(resident),
(robot)-[:IMPLIES {}]->(machine),
(robot)-[:IMPLIES {}]->(resident),
(resident)-[:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "LIVES_IN", properties: ["since :: ANY NOT NULL"], constraints: []}]->(city),
(person)-[:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "WORKS_FOR", properties: ["role :: STRING"], constraints: []}]->(company),
(any)-[:RELATIONSHIP_TYPE {relationshipType: "STAYED_IN", constraints: ["CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE r.endDate IS :: DATE", "CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS NOT NULL", "CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS :: DATE"]}]->(any)
Combine SHOW CURRENT GRAPH TYPE with other Cypher clausesIntroduced in Neo4j 2026.05
The SHOW CURRENT GRAPH TYPE command can be combined with general Cypher® clauses in a single query.
For example, splitting the graph type specification into separate strings.
SHOW CURRENT GRAPH TYPE
YIELD specification
FILTER specification <> '{}' (1)
WITH split(specification, '\r\n') AS specificationLines (2)
WITH specificationLines[1..-1] AS elementLines (3)
WITH [line IN elementLines | rtrim(trim(line), ',')] AS graphTypeLines (4)
UNWIND graphTypeLines AS graphTypeElement
RETURN graphTypeElement
| 1 | Filter out the empty graph type. |
| 2 | Split STRING definition into separate lines. |
| 3 | Remove the opening and closing lines of the graph type ({ and }). |
| 4 | Remove leading indention and trailing commas. |
+--------------------------------------------------------------------------------------------------------------------+
| graphTypeElement |
+--------------------------------------------------------------------------------------------------------------------+
| "(:`City` => {`name` :: STRING NOT NULL, `population` :: INTEGER})" |
| "(:`Company` => {`address` :: STRING, `name` :: STRING})" |
| "(:`Person` => :`Resident` {`name` :: STRING, `ssn` :: INTEGER})" |
| "(:`Pet` => :`Animal`&`Resident` {`healthCertificate` :: STRING, `insuranceNumber` :: INTEGER, `name` :: STRING})" |
| "(:`Robot` => :`Machine`&`Resident` {`application` :: STRING NOT NULL, `id` :: INTEGER NOT NULL})" |
| "(:`Resident`)-[:`LIVES_IN` => {`since` :: ANY NOT NULL}]->(:`City` =>)" |
| "(:`Person` =>)-[:`WORKS_FOR` => {`role` :: STRING}]->(:`Company` =>)" |
| "CONSTRAINT `constraint_1324d6fc` FOR (`n`:`Company` =>) REQUIRE (`n`.`address`) IS UNIQUE" |
| "CONSTRAINT `company_name` FOR (`n`:`Company` =>) REQUIRE (`n`.`name`) IS KEY" |
| "CONSTRAINT `constraint_5d8979dd` FOR (`n`:`Person` =>) REQUIRE (`n`.`name`, `n`.`ssn`) IS KEY" |
| "CONSTRAINT `constraint_bbcb9835` FOR (`n`:`Pet` =>) REQUIRE (`n`.`healthCertificate`) IS UNIQUE" |
| "CONSTRAINT `constraint_550b510e` FOR (`n`:`Pet` =>) REQUIRE (`n`.`insuranceNumber`) IS KEY" |
| "CONSTRAINT `animal_id` FOR (`n`:`Animal`) REQUIRE (`n`.`id`) IS UNIQUE" |
| "CONSTRAINT `resident_address` FOR (`n`:`Resident`) REQUIRE (`n`.`address`) IS :: STRING" |
+--------------------------------------------------------------------------------------------------------------------+
14 rows
|
When combining |
Return columns
The columns returned by SHOW CURRENT GRAPH TYPE and SHOW CURRENT GRAPH TYPE AS GRAPH are different.
SHOW CURRENT GRAPH TYPE columns
There is one return column for SHOW CURRENT GRAPH TYPE: specification.
It is returned by default.
| Column | Description | Type |
|---|---|---|
|
The graph type of the current database using the canonical form.
This can be used in an |
|
SHOW CURRENT GRAPH TYPE AS GRAPH columnsIntroduced in Neo4j 2026.06
There are two return columns for SHOW CURRENT GRAPH TYPE AS GRAPH: nodes and relationships.
They are returned by default.
| Column | Description | Type |
|---|---|---|
|
A list of virtual nodes representing the node element types, separate node labels, node constraints not belonging to any node element type, and nodes used to represent empty endpoints on relationships. Default Output |
|
|
A list of virtual relationships representing the relationship element types, relationship constraints not belonging to any relationship element type, and label implications in node element types. Default Output |
|
The graph returned by SHOW CURRENT GRAPH TYPE AS GRAPH is a virtual graph.
A virtual graph is a graph projection that exists only for the duration of a query.
Virtual nodes and relationships are constructed purely to represent data in a graph-shaped format, are not persisted, and should not be written to.
Nodes and relationships in a virtual graph have negative IDs.
|
Virtual nodes
There are three different virtual nodes used to represent parts of the graph type.
-
Node element type virtual nodes represent a node element type in the graph type. They contain the identifying label, property specifications, and any key or uniqueness constraints tied to the node element type.
-
Node label virtual nodes represent node labels that are not identifying a node element type. Either node constraints that are not tied to any node element type, labels that are implied on node element types, or labels used as endpoints on relationship element types. The constraints are collected per label, meaning there is one node per group of constraints sharing a label, not one per constraint. They contain the label and any constraints belonging to it.
-
Empty relationship endpoint virtual nodes represent the empty endpoints of relationships. Either an unconstrained endpoint of a relationship element type or the empty end point of a relationship constraint not belonging to a relationship element type. They contain no additional information.
Node element type virtual nodes all have the label NodeElementType, with their information stored in their properties.
For example, (:NodeElementType {label: "Person", properties: ["name :: STRING", "ssn :: INTEGER"], constraints: ["CONSTRAINT constraint_5d8979dd FOR (n:Person =>) REQUIRE (n.name, n.ssn) IS KEY"]}).
| Property | Description | Type |
|---|---|---|
|
The identifying label of the node element type. |
|
|
Any properties defined on the node element type, otherwise an empty list.
The format of the strings are the same as given in the graph type definition, for example |
|
|
Any key or uniqueness constraints belonging to the node element type, otherwise an empty list. The constraints are represented by their string descriptions in the graph type definition. |
|
Node label virtual nodes all have the label NodeLabel, with their information stored in their properties.
For example, (:NodeLabel {label: "Animal", constraints: ["CONSTRAINT animal_id FOR (n:Animal) REQUIRE n.id IS UNIQUE"]}) and (:NodeLabel {label: "Machine", constraints: []}).
| Property | Description | Type |
|---|---|---|
|
The label of the node constraints or being referenced in an element type. |
|
|
Any constraints belonging to the label, otherwise an empty list. The constraints are represented by their string descriptions in the graph type definition. |
|
Empty relationship endpoint virtual nodes have the label AnyLabel and no properties, as they store no additional information.
Virtual relationships
There are three different virtual relationships used to represent parts of the graph type.
-
Relationship element type virtual relationships represent a relationship element type in the graph type. They contain the identifying relationship type, property specifications and any key or uniqueness constraints tied to the relationship element type.
-
Relationship constraint virtual relationships represent relationship constraints that are not tied to any relationship element type. They are collected per relationship type, meaning there is one relationship per group of constraints sharing a relationship type, not one per constraint. They contain the relationship type and constraints belonging to it.
-
Label implication virtual relationships represent a label implication of a node element type. They contain no additional information.
Relationship element type virtual relationships all have the relationship type RELATIONSHIP_ELEMENT_TYPE, with their information stored in their properties.
For example, [:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "LIVES_IN", properties: ["since :: ANY NOT NULL"], constraints: []}].
| Property | Description | Type |
|---|---|---|
|
The identifying relationship type of the relationship element type. |
|
|
Any properties defined on the relationship element type, otherwise an empty list.
The format of the strings are the same as given in the graph type definition, for example |
|
|
Any key or uniqueness constraints belonging to the relationship element type, otherwise an empty list. The constraints are represented by their string descriptions in the graph type definition. |
|
Relationship constraint virtual relationships all have the relationship type RELATIONSHIP_TYPE, with their information stored in their properties.
For example, [:RELATIONSHIP_TYPE {relationshipType: "STAYED_IN", constraints: ["CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE r.endDate IS :: DATE", "CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS NOT NULL", "CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS :: DATE"]}].
| Property | Description | Type |
|---|---|---|
|
The relationship type of the relationship constraints. |
|
|
Any constraints belonging to the relationship, otherwise an empty list. The constraints are represented by their string descriptions in the graph type definition. |
|
Label implication virtual relationships have relationship type IMPLIES and no properties, as they store no additional information.
Constraints in SHOW CURRENT GRAPH TYPE
Constraints created using the CREATE CONSTRAINT command (i.e. not added with ALTER CURRENT GRAPH TYPE SET, ADD, or ALTER) are automatically added to the graph type.
They will therefore appear in the SHOW CURRENT GRAPH TYPE result.
CREATE CONSTRAINT commandCREATE CONSTRAINT car_constraint FOR (c:Car) REQUIRE c.licensePlate IS UNIQUE
specification of the full graph typeSHOW CURRENT GRAPH TYPE YIELD specification
+--------------------------------------------------------------------------------------------------------------------------+
| specification |
+--------------------------------------------------------------------------------------------------------------------------+
| "{ |
| (:`City` => {`name` :: STRING NOT NULL, `population` :: INTEGER}), |
| (:`Company` => {`address` :: STRING, `name` :: STRING}), |
| (:`Person` => :`Resident` {`name` :: STRING, `ssn` :: INTEGER}), |
| (:`Pet` => :`Animal`&`Resident` {`healthCertificate` :: STRING, `insuranceNumber` :: INTEGER, `name` :: STRING}), |
| (:`Robot` => :`Machine`&`Resident` {`application` :: STRING NOT NULL, `id` :: INTEGER NOT NULL}), |
| (:`Resident`)-[:`LIVES_IN` => {`since` :: ANY NOT NULL}]->(:`City` =>), |
| (:`Person` =>)-[:`WORKS_FOR` => {`role` :: STRING}]->(:`Company` =>), |
| CONSTRAINT `constraint_d7524c38` FOR (`n`:`Company` =>) REQUIRE (`n`.`address`) IS UNIQUE, |
| CONSTRAINT `company_name` FOR (`n`:`Company` =>) REQUIRE (`n`.`name`) IS KEY, |
| CONSTRAINT `constraint_bb1018eb` FOR (`n`:`Person` =>) REQUIRE (`n`.`name`, `n`.`ssn`) IS KEY, |
| CONSTRAINT `constraint_302a3693` FOR (`n`:`Pet` =>) REQUIRE (`n`.`healthCertificate`) IS UNIQUE, |
| CONSTRAINT `constraint_aa881a72` FOR (`n`:`Pet` =>) REQUIRE (`n`.`insuranceNumber`) IS KEY, |
| CONSTRAINT `animal_id` FOR (`n`:`Animal`) REQUIRE (`n`.`id`) IS UNIQUE, |
| CONSTRAINT `car_constraint` FOR (`n`:`Car`) REQUIRE (`n`.`licensePlate`) IS UNIQUE, |
| CONSTRAINT `resident_address` FOR (`n`:`Resident`) REQUIRE (`n`.`address`) IS :: STRING, |
| CONSTRAINT `stayed_in_endDate` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`endDate`) IS :: DATE, |
| CONSTRAINT `stayed_in_startDateExistence` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`startDate`) IS NOT NULL, |
| CONSTRAINT `stayed_in_startDateType` FOR ()-[`r`:`STAYED_IN`]->() REQUIRE (`r`.`startDate`) IS :: DATE |
| }" |
+--------------------------------------------------------------------------------------------------------------------------+
SHOW CURRENT GRAPH TYPE AS GRAPH YIELD nodes, relationships
Four entities in the result are worth noting:
-
NodeElementType: a virtual node representing a node element type in the graph type. -
NodeLabel: a virtual node representing a node label in the graph type. -
AnyLabel: relationship element types with unconstrained endpoints are represented by a virtual any-node with the labelAnyLabeland no properties. Each relationship gets its ownAnyLabelnode. -
IMPLIES: when a node element type implies another label, the two are connected by a relationship of typeIMPLIESwith no properties.
For more information, see Show graph types → Virtual nodes and Virtual relationships.
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes | relationships |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [(:AnyLabel {}), (:NodeElementType {label: "City", properties: ["name :: STRING NOT NULL", | [[:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:IMPLIES {}], [:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "LIVES_IN", |
| "population :: INTEGER"], constraints: []}), (:NodeElementType {label: "Company", | properties: ["since :: ANY NOT NULL"], constraints: []}], [:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "WORKS_FOR", properties: |
| properties: ["address :: STRING", "name :: STRING"], constraints: [ | ["role :: STRING"], constraints: []}], [:RELATIONSHIP_TYPE {relationshipType: "STAYED_IN", constraints: [ |
| "CONSTRAINT constraint_d7524c38 FOR (n:Company =>) REQUIRE n.address IS UNIQUE", | "CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE r.endDate IS :: DATE", |
| "CONSTRAINT company_name FOR (n:Company =>) REQUIRE n.name IS KEY"]}), (:NodeElementType | "CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS NOT NULL", |
| {label: "Person", properties: ["name :: STRING", "ssn :: INTEGER"], constraints: [ | "CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS :: DATE"]}]] |
| "CONSTRAINT constraint_bb1018eb FOR (n:Person =>) REQUIRE (n.name, n.ssn) IS KEY"]}), (:NodeElementType | |
| {label: "Pet", properties: ["healthCertificate :: STRING", "insuranceNumber :: INTEGER", "name :: STRING"], | |
| constraints: ["CONSTRAINT constraint_302a3693 FOR (n:Pet =>) REQUIRE n.healthCertificate IS UNIQUE", | |
| "CONSTRAINT constraint_aa881a72 FOR (n:Pet =>) REQUIRE n.insuranceNumber IS KEY"]}), (:NodeElementType | |
| {label: "Robot", properties: ["application :: STRING NOT NULL", "id :: INTEGER NOT NULL"], constraints: []}), | |
| (:NodeLabel {label: "Animal", constraints: ["CONSTRAINT animal_id FOR (n:Animal) REQUIRE n.id IS UNIQUE"]}), | |
| (:NodeLabel {label: "Car", constraints: ["CONSTRAINT car_constraint FOR (n:Car) REQUIRE n.licensePlate IS UNIQUE"]}), | |
| (:NodeLabel {label: "Machine", constraints: []}), (:NodeLabel {label: "Resident", constraints: [ | |
| "CONSTRAINT resident_address FOR (n:Resident) REQUIRE n.address IS :: STRING"]})] | |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Together, these two lists form the following graph:
(city:NodeElementType {label: "City", properties: ["name :: STRING NOT NULL", "population :: INTEGER"], constraints: []}),
(company:NodeElementType {label: "Company", properties: ["address :: STRING", "name :: STRING"], constraints: ["CONSTRAINT constraint_d7524c38 FOR (n:Company =>) REQUIRE n.address IS UNIQUE", "CONSTRAINT company_name FOR (n:Company =>) REQUIRE n.name IS KEY"]}),
(person:NodeElementType {label: "Person", properties: ["name :: STRING", "ssn :: INTEGER"], constraints: ["CONSTRAINT constraint_bb1018eb FOR (n:Person =>) REQUIRE (n.name, n.ssn) IS KEY"]}),
(pet:NodeElementType {label: "Pet", properties: ["healthCertificate :: STRING", "insuranceNumber :: INTEGER", "name :: STRING"], constraints: ["CONSTRAINT constraint_302a3693 FOR (n:Pet =>) REQUIRE n.healthCertificate IS UNIQUE", "CONSTRAINT constraint_aa881a72 FOR (n:Pet =>) REQUIRE n.insuranceNumber IS KEY"]}),
(robot:NodeElementType {label: "Robot", properties: ["application :: STRING NOT NULL", "id :: INTEGER NOT NULL"], constraints: []}),
(animal:NodeLabel {label: "Animal", constraints: ["CONSTRAINT animal_id FOR (n:Animal) REQUIRE n.id IS UNIQUE"]}),
(car:NodeLabel {label: "Car", constraints: ["CONSTRAINT car_constraint FOR (n:Car) REQUIRE n.licensePlate IS UNIQUE"]}),
(machine:NodeLabel {label: "Machine", constraints: []}),
(resident:NodeLabel {label: "Resident", constraints: ["CONSTRAINT resident_address FOR (n:Resident) REQUIRE n.address IS :: STRING"]}),
(any:AnyLabel {}),
(person)-[:IMPLIES {}]->(resident),
(pet)-[:IMPLIES {}]->(animal),
(pet)-[:IMPLIES {}]->(resident),
(robot)-[:IMPLIES {}]->(machine),
(robot)-[:IMPLIES {}]->(resident),
(resident)-[:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "LIVES_IN", properties: ["since :: ANY NOT NULL"], constraints: []}]->(city),
(person)-[:RELATIONSHIP_ELEMENT_TYPE {relationshipType: "WORKS_FOR", properties: ["role :: STRING"], constraints: []}]->(company),
(any)-[:RELATIONSHIP_TYPE {relationshipType: "STAYED_IN", constraints: ["CONSTRAINT stayed_in_endDate FOR ()-[r:STAYED_IN]->() REQUIRE r.endDate IS :: DATE", "CONSTRAINT stayed_in_startDateExistence FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS NOT NULL", "CONSTRAINT stayed_in_startDateType FOR ()-[r:STAYED_IN]->() REQUIRE r.startDate IS :: DATE"]}]->(any)
Graph type elements in SHOW CONSTRAINTS
Each element in a graph type is implemented with constraints.
Whatever is added in a graph type is accordingly returned by the SHOW CONSTRAINTS command.
For full information about this command, including its return columns, see Show constraints.
Showing constraints requires the SHOW CONSTRAINTS privilege.
|
Of particular interest are the enforcedLabel and classification columns returned by SHOW CONSTRAINTS.
enforcedLabel returns the implied node labels belonging to a node element type and the source and target node labels belonging to a relationship element type.
The classification describes the status of a constraint in a graph type, with three possible return values:
classification |
Applies to |
|---|---|
|
Property existence and property type constraints defined on an identifying node label/relationship type in a node or relationship element type, or the node label existence constraints, relationship target label constraints, or relationship source label constraints belonging to node or relationship element types. |
|
Key and property uniqueness constraints, regardless of whether defined on an identifying or non-identifying node label or relationship type. |
|
For more information, see Show constraints → Return columns.
SHOW CONSTRAINTS YIELD name, type, labelsOrTypes, enforcedLabel, classification
ORDER BY labelsOrTypes
+------------------------------------------------------------------------------------------------------------+
| name | type | labelsOrTypes | enforcedLabel | classification |
+------------------------------------------------------------------------------------------------------------+
| "animal_id" | "NODE_PROPERTY_UNIQUENESS" | ["Animal"] | NULL | "undesignated" |
| "car_constraint" | "NODE_PROPERTY_UNIQUENESS" | ["Car"] | NULL | "undesignated" |
| "constraint_22a8753a" | "NODE_PROPERTY_EXISTENCE" | ["City"] | NULL | "dependent" |
| "constraint_83085900" | "NODE_PROPERTY_TYPE" | ["City"] | NULL | "dependent" |
| "constraint_ff70b222" | "NODE_PROPERTY_TYPE" | ["City"] | NULL | "dependent" |
| "company_name" | "NODE_KEY" | ["Company"] | NULL | "undesignated" |
| "constraint_437f8bc9" | "NODE_PROPERTY_TYPE" | ["Company"] | NULL | "dependent" |
| "constraint_56444b08" | "NODE_PROPERTY_TYPE" | ["Company"] | NULL | "dependent" |
| "constraint_d7524c38" | "NODE_PROPERTY_UNIQUENESS" | ["Company"] | NULL | "undesignated" |
| "constraint_2fd51eaf" | "RELATIONSHIP_TARGET_LABEL" | ["LIVES_IN"] | "City" | "dependent" |
| "constraint_9dfe66aa" | "RELATIONSHIP_SOURCE_LABEL" | ["LIVES_IN"] | "Resident" | "dependent" |
| "constraint_f26c0c3d" | "RELATIONSHIP_PROPERTY_EXISTENCE" | ["LIVES_IN"] | NULL | "dependent" |
| "constraint_77504979" | "NODE_PROPERTY_TYPE" | ["Person"] | NULL | "dependent" |
| "constraint_82630a6c" | "NODE_LABEL_EXISTENCE" | ["Person"] | "Resident" | "dependent" |
| "constraint_96f964fb" | "NODE_PROPERTY_TYPE" | ["Person"] | NULL | "dependent" |
| "constraint_bb1018eb" | "NODE_KEY" | ["Person"] | NULL | "undesignated" |
| "constraint_302a3693" | "NODE_PROPERTY_UNIQUENESS" | ["Pet"] | NULL | "undesignated" |
| "constraint_aa881a72" | "NODE_KEY" | ["Pet"] | NULL | "undesignated" |
| "constraint_afe0a8de" | "NODE_LABEL_EXISTENCE" | ["Pet"] | "Resident" | "dependent" |
| "constraint_c2c72e5b" | "NODE_LABEL_EXISTENCE" | ["Pet"] | "Animal" | "dependent" |
| "constraint_c79712fe" | "NODE_PROPERTY_TYPE" | ["Pet"] | NULL | "dependent" |
| "constraint_e6253a9f" | "NODE_PROPERTY_TYPE" | ["Pet"] | NULL | "dependent" |
| "constraint_f44978e8" | "NODE_PROPERTY_TYPE" | ["Pet"] | NULL | "dependent" |
| "resident_address" | "NODE_PROPERTY_TYPE" | ["Resident"] | NULL | "independent" |
| "constraint_12d19793" | "NODE_LABEL_EXISTENCE" | ["Robot"] | "Machine" | "dependent" |
| "constraint_5d3b927" | "NODE_PROPERTY_TYPE" | ["Robot"] | NULL | "dependent" |
| "constraint_6e2d3d78" | "NODE_LABEL_EXISTENCE" | ["Robot"] | "Resident" | "dependent" |
| "constraint_8993edce" | "NODE_PROPERTY_TYPE" | ["Robot"] | NULL | "dependent" |
| "constraint_94c37fdc" | "NODE_PROPERTY_EXISTENCE" | ["Robot"] | NULL | "dependent" |
| "constraint_e5820d7e" | "NODE_PROPERTY_EXISTENCE" | ["Robot"] | NULL | "dependent" |
| "constraint_57239b68" | "RELATIONSHIP_SOURCE_LABEL" | ["WORKS_FOR"] | "Person" | "dependent" |
| "constraint_d7a3733b" | "RELATIONSHIP_TARGET_LABEL" | ["WORKS_FOR"] | "Company" | "dependent" |
| "constraint_df70c64c" | "RELATIONSHIP_PROPERTY_TYPE" | ["WORKS_FOR"] | NULL | "dependent" |
+------------------------------------------------------------------------------------------------------------+
All dependent node label existence, relationship source/target label, property existence, and property types constraints have a generated name.
This is because they cannot be named when defined in their respective node and relationship element types.
The createStatement column will also return null for these constraints, because they cannot be created through a CREATE CONSTRAINT command.
|