Edge Table Management
This document describes the commands for managing edge tables in the graph database.
Overview
Edge tables define the relationships between vertex tables in a graph database. Each edge represents a connection between two vertices, with optional properties stored as columns.
Create Edge Table
Key Features:
- Define directed or undirected edges (currently only support directed edges).
- Specify source and target vertex tables
- Add properties as columns with data types
- Optional reverse edge creation
- Control edge uniqueness constraints
Syntax
CREATE DIRECTED | UNDIRECTED EDGE <edge_table_name>
(
FROM <source_vertex_table_name>
TO <target_vertex_table_name>,
<column_name> <data_type> [NOT NULL | NULL ],
<column_name> <data_type> ...
)
[ WITH REVERSE EDGE <reverse_edge_table_name> ]
[ EDGE_UNIQUENESS = SINGLE | MULTIPLE ]
EDGE_UNIQUENESS:
- SINGLE: There will be at most one edge with value
(src, dst, prop1, prop2, ...)
. - MULTIPLE: Allow multiple edges with the same
(src, dst, prop1, prop2, ...)
.
Example
Create a edge table named Buy
, with sourcee vertex table User
and target
vertex table Item
. And edge table has three columns, namely col1
, col2
and
col3
. And requires col1
has an NOT NULL constraint.
And also create an edge table named rBuy
which store the reverse direction of
Buy
.
CREATE DIRECTED EDGE Buy
(
FROM User
TO Item,
col1 INTEGER NOT NULL,
col2 VARCHAR,
col3 VARCHAR
)
WITH REVERSE EDGE rBuy.
Drop Edge Table
Drop an edge table with given name.
Syntax
DROP EDGE <edge_table_name>
Example
DROP EDGE Buy
Describe Edge Table
Describe meta information about an edge table
Syntax
DESCRIBE EDGE <edge_table_name>
Example
DESCRIBE EDGE Buy
List Edge Tables
List all edge table names.
Syntax
LIST EDGE
Rename Columm Name
Rename table column if both table and column exists.
ALTER TABLE [IF EXISTS] <table_name>
RENAME COLUMN [IF EXISTS] <column_name> TO <new_column_name>
Example
ALTER TABLE KNOWS RENAME COLUMN age To new_age