This page introduces statements for managing node and edge schemas in a graph.
Showing Schemas
Retrieve node schemas of the current graph:
SHOW NODE SCHEMA
Retrieve edge schemas of the current graph:
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 one shard). - Edge schemas: Stored in
_edgeSchema
(all schemas) and_edgeSchema_shard_<id>
(schemas with data stored in one shard).
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 comment 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 of each schema. Each edge schema is counted based on the distinct combinations of the start and end node schemas it connects.
Creating Schemas
You can use the ALTER GRAPH
statement to add node and edge schemas to a graph.
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 DATE}]->(),
StudyAt ()-[]->()
}
References:
Altering Schema Name and Comment
The ALTER NODE
or ALTER EDGE
statement can be used to alter the name and comment of 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
To update the comment of the node schema User
in the current graph:
ALTER NODE User COMMENT "Self-registration"
To update the comment of the edge schema Follows
in the current graph:
ALTER EDGE Follows COMMENT "From user to user"
You can perform both operations—renaming a schema and updating its comment—in a single ALTER NODE
or ALTER EDGE
statement:
ALTER NODE User RENAME TO User_s2 COMMENT "Self-registration"
ALTER EDGE Follows RENAME TO Follow 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