DEV Community

Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Create Vertex in Apache AGE

In Apache AGE, data is stored in edges and vertices. In this blog, I will tell you how you can create vertex and how you can store data in it.
Firstly, in vertex we have vertex name, formally we call it label.
Secondly, we can also store data related to the vertex in it. The data is stored in key value pair.
Gerneral Form
SELECT *
FROM cypher('graph_name', $$
CREATE (:LabelName {PropertyKey: 'PropertyValue', ...})
$$) as (anyName agtype);

Create single vertex
SELECT *
FROM cypher('graph_name', $$
CREATE (n)
$$) as (v agtype);

Create a vertex with a label
SELECT *
FROM cypher('graph_name', $$
CREATE (:Person)
$$) as (v agtype);

Create vertex and add labels and properties
SELECT *
FROM cypher('graph_name', $$
CREATE (:Person {name: 'Andres', title: 'Developer'})
$$) as (v agtype);

Return newly created node
SELECT *
FROM cypher('graph_name', $$
CREATE (a {name: 'Andres'})
RETURN a
$$) as (a agtype);

For more details visit: https://age.apache.org/overview/

AGE Github Link: https://github.com/apache/age

AGE Viewer Github Link: https://github.com/apache/age-viewer

Top comments (0)