This page introduces statements for managing node and edge schemas in a graph.
Showing Schemas
The SHOW NODE SCHEMA
and SHOW EDGE SCHEMA
statements retrieve information about node and edge schemas of the current graph.
SHOW NODE SCHEMA
SHOW EDGE SCHEMA
The information about schemas is organized into different tables:
- Node schemas: Stored in
_nodeSchema
(all schemas) and_nodeSchema_shard_<id>
(schemas with data stored in shard<id>
). - Edge schemas: Stored in
_edgeSchema
(all schemas) and_edgeSchema_shard_<id>
(schemas with data stored in shard<id>
).
Ultipa Manager has been configured to display only the
_nodeSchema
and_edgeSchema
tables.
Each table includes the following fields:
Field |
Description |
---|---|
id |
The id of the schema. |
name |
The name assigned to the schema. |
description |
The description given to the schema. |
status |
The current state of the schema, which can only be CREATED . |
properties |
The properties of the schema, with each property contains name , id , type , description , index , fulltext , nullable , lte , read , write , encrypt , and is_deleted . |
There is another table, _graphCount
, which provides an overview of the number of nodes and edges for each schema. Each edge schema is counted based on the distinct combinations of the start and end node schemas it connects.
Creating Schemas
The ALTER GRAPH
statement can be used to add node and edge schemas to a graph.
<alter graph statement> ::=
"ALTER GRAPH" <graph name> { <add node schemas> | <add edge schemas> }
<add node schemas> ::=
"ADD NODE" "{" <add node schema> [ { "," <add node schema> }... ] "}"
<add node schema> ::=
<schema name> "(" [ <property types> ] ")"
<add edge schemas> ::=
"ADD EDGE" "{" <add edge schema> [ { "," <add edge schema> }... ] "}"
<add edge schema> ::=
<schema name> "()-[" [ <property types> ] "]->()"
<property types> ::=
"{" <property type> [ { "," <property type> }... ] "}"
<property type> ::=
<property name> <property value type> [ <property description> ]
Details
Each node or edge schema is defined by the following:
- Schema name. See naming conventions.
- Associated properties (Optional). Each property is defined by the following:
- Property name. See naming conventions.
- Property value type. See all property value types.
- Property description (Optional): Description of the property.
To add node schemas User
, Club
, and School
to the graph g1
:
ALTER GRAPH g1 ADD NODE {
User ({username string COMMENT "Username, cannot be null", gender string}),
Club ({name string, since uint32}),
School ()
}
To add edge schemas Follows
and StudyAt
to the graph g1
:
ALTER GRAPH g1 ADD EDGE {
Follows ()-[{createdOn datetime}]->(),
StudyAt ()-[]->()
}
Renaming Schemas
The ALTER NODE
or ALTER EDGE
statement can be used to rename a node or edge schema in the current graph.
To rename the node schema School
to University
in the current graph:
ALTER NODE School RENAME TO University
To rename the edge schema Follows
to Follow
in the current graph:
ALTER EDGE Follows RENAME TO Follow
Altering Schema Descriptions
The ALTER NODE
or ALTER EDGE
statement can be used to alter the description of a node or edge schema in the current graph.
To update the description of the node schema User
in the current graph:
ALTER NODE User COMMENT "Users from self-registration"
To update the description of the edge schema Follows
in the current graph:
ALTER EDGE Follows COMMENT "From user to user"
Dropping Schemas
The ALTER GRAPH
statement can be used to delete node and edge schemas from a graph. Dropping a node or edge schema deletes the schema along with the nodes or edges belonging to it. Note that the deletion of a node leads to the removal of all edges that are connected to it. The two default
schemas cannot be dropped.
The schema dropping operation runs as a job, you may run SHOW JOB <id?>
afterward to verify its completion.
To drop a node schema User
from the graph g1
:
ALTER GRAPH g1 DROP NODE User
To drop edge schemas Follows
and StudyAt
from the graph g1
:
ALTER GRAPH g1 DROP EDGE Follows, StudyAt