DEV Community

Maruf13
Maruf13

Posted on

Apache AGE Intro

Apache AGE is a PostgreSQL extension that provides graph database functionality. AGE is inspired by Bitnine’s fork of PostgreSQL 10, AgensGraph, which is a multi-model database. The goal of the project is to create single storage that can handle both relational and graph model data so that users can use standard ANSI SQL along with openCypher, the Graph query language.

✔️ Graphs:

A graph consists of a set of vertices/nodes and edges, which shows a map of properties. A node is independent block in the graph. An edge creates a directed connection between two vertices.

Create a Graph
To create a graph, use below function from ag_catalog namespace:

create_graph(graph_name); #Returns: void
Example:
SELECT * FROM ag_catalog.create_graph('graph_name');
Enter fullscreen mode Exit fullscreen mode

Cypher Query Format
Cypher queries are-

cypher(graph_name, query_string, parameters) 
    #Return A SET OF records 
    #parameters is optional & by default NULL
Example:
SELECT * FROM cypher('graph_name', $$/* Cypher Query Here */ $$) 
AS (result1 agtype, result2 agtype);
Enter fullscreen mode Exit fullscreen mode

Delete a Graph
To delete a graph, use the below function, form ag_catalog namespace:

drop_graph(graph_name, cascade); #Returns: void
Example:
SELECT * FROM ag_catalog.drop_graph('graph_name', true);
Enter fullscreen mode Exit fullscreen mode

✔️ References:

  1. https://age.apache.org/
  2. https://github.com/apache/age
  3. https://www.interdb.jp/pg/index.html
  4. https://joefagan.github.io/age_docs/

Top comments (0)