DEV Community

Moiz Ibrar
Moiz Ibrar

Posted on • Updated on

Here are some examples of using Apache Age with PostgreSQL:

Creating a graph schema:

CREATE TABLE person (id int PRIMARY KEY, name text);
CREATE TABLE knows (src int REFERENCES person(id), dst int REFERENCES person(id));

Enter fullscreen mode Exit fullscreen mode

Adding nodes and edges to the graph:

INSERT INTO person (id, name) VALUES (1, 'Alice');
INSERT INTO person (id, name) VALUES (2, 'Bob');
INSERT INTO knows (src, dst) VALUES (1, 2);
Enter fullscreen mode Exit fullscreen mode

Querying the graph using GSQL:

SELECT p.name, k.dst FROM person p, knows k WHERE p.id=k.src;
Enter fullscreen mode Exit fullscreen mode

This query returns the names of people who know each other.
**
Visualizing the Graph with GAdmin**

Once you have created your graph schema and added nodes and edges to the graph, you can use GAdmin to visualize the graph. GAdmin provides a visual representation of the graph, with nodes and edges displayed as circles and lines. You can use the visualization to explore the relationships between nodes and edges, and to identify patterns in the graph data.

Conclusion

These are just a few examples of how you can use Apache Age with PostgreSQL to model, query, and visualize graph data. The possibilities are endless, and you can use Apache Age to model and query any type of graph data.

Apache-Age:-https://age.apache.org/
GitHub:-https://github.com/apache/age

Top comments (0)