DEV Community

Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Create Vertex (Node) Label in Apache AGE

Vertex Labels are used to identify nodes and group similar node to gather. For instance, if we want to store information about employees in any organization, we can store that information in nodes and we can label those nodes as employee. This will enable us to query node data faster. Because when we write query to get any particular node data from particular vertex/ node label, the Database Management System will be able to quickly go to all nodes of that particular label and access the desired node.

General Form:
SELECT create_vlabel('GraphName','LabelName');

Explanation:
The first argument of the function create_vlabel is the graph name and second argument is the desired name of the label.

Important Thing to Remember:
We have seen queries like:

SELECT *
FROM cypher('graph_name', $$
CREATE (:Person {name: 'Andres', title: 'Developer'})
$$) as (v agtype);

The label provides here is Person. When we run such queries, this newly created node's data will be stored in the same place where data of other nodes with Person label are stored.
If Person label does not exist already, this query will create a Person label automatically and store that node data against Person label.

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)