An Ultipa instance can host multiple graphs, each representing a dataset of interconnected nodes and edges.
To show graphs in the database:
GQLSHOW GRAPHS
Each graph provides the following essential metadata:
Field | Description |
|---|---|
graph_name | The unique name of the graph. |
current | Whether the graph is the current graph. |
Ultipa supports two types of graphs: Closed Graph and Open Graph. This design offers both flexibility and control, supporting workflows ranging from agile exploration to production-grade applications demanding strict data integrity requirements.
A closed graph requires that any node to be inserted must conform to a defined node type, and any edge to be inserted must conform to a defined edge type. This ensures consistent structure, guaranteeing high data integrity and consistency.
Learn more about closed graphs →
The open graph is schema-free, requiring no explicit schema definitions before data insertion. You can directly insert nodes and edges into the graph, and their labels and properties are created on the fly. This offers maximum flexibility for early-stage data exploration.
Learn more about open graphs →
You can use the IF NOT EXISTS clause to prevent errors when attempting to create a graph that already exists. It allows the statement to be safely executed.
GQLCREATE GRAPH IF NOT EXISTS myGraph
This creates the graph myGraph only if a graph with that name does not exist. If myGraph already exists, the statement is ignored without throwing an error.
To drop the graph myGraph:
GQLDROP GRAPH myGraph
The IF EXISTS clause is used to prevent errors when attempting to delete a graph that does not exist. It allows the statement to be safely executed.
GQLDROP GRAPH IF EXISTS myGraph
This deletes the graph myGraph only if a graph with that name does exist. If myGraph does not exist, the statement is ignored without throwing an error.
The truncating operation deletes nodes and edges from the graph while preserving the graph itself and its graph type (closed graph) or labels (open graph).
You may truncate the entire graph, all nodes or edges, or nodes or edges with a specific label. Note that truncating nodes will also remove any edges connected to them.
To truncate myGraph:
GQLTRUNCATE myGraph
To truncate all nodes in myGraph, note that all edges will be removed too:
GQLTRUNCATE NODE * ON myGraph
To truncate all edges in myGraph:
GQLTRUNCATE EDGE * ON myGraph
In a closed graph, you can truncate nodes or edges of a specified schema. For example, to truncate all User nodes in myGraph, note that all edges connected to User nodes will be removed too:
GQLTRUNCATE NODE User ON myGraph
To truncate all Follows edges in myGraph:
GQLTRUNCATE EDGE Follows ON myGraph
Graph names must be unique. Each graph name must:
_).Graph type names must be unique. Each graph type name must:
_).Each schema name or label must:
_) or a tilde (~).`).In a closed graph, node schema names must be unique, and edge schema names must be unique. However, a node schema and an edge schema may share the same name.
Each property name must:
_) or a tilde (~).`).In a closed graph, property names must be unique among a node schema or an edge schema.