DEV Community

Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Create Edge Label in Apache AGE

Edge Labels are used to identify edges and group similar edges to gather. For instance, if we want to store relation between employees and department in any organization, we can store that relation in edges and we can label those edges as works_in. This will enable us to query edge data faster. Because when we write query to get any particular edge data from particular edge label, the Database Management System will be able to quickly go to all edges of that particular label and access the desired edge.

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

Explanation:
The first argument of the function create_elabel 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', $$
MATCH (a:VertexLabelName), (b:VertexLabelName)
WHERE a.PropertyName = 'AnyThing' AND b.PropertyName = 'AnyThing'
CREATE (a)-[e:works_in {edgePropertyName:'Anything', ...}]->(b)
RETURN e
$$) as (e agtype);

The label provides here is works_in. When we run such queries, this newly created edge's data will be stored in the same place where data of other edges with works_in label are stored.
If works_in label does not exist already, this query will create a works_in label automatically and store that edge data against works_in 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

Latest comments (0)