Before we start mastering anything, it is imperative we understand what a graph is. A graph consists of a set of vertices and edges, while, each vertex and edge has a map or certain properties.
From now on we'll be assuming you have Apache AGE installed and configured correctly with postgreSQL. Start the postgres server with the following command
pg_ctl -D agedemo -l logfile start
In my case, I have created a database named agedemo and connected to it with the command:
psql agedemo
Now, I've created a graph called Halo based on the game as follows:
The load and SET lines are standard for setting up the configs for Apache AGE. The create_graph is a function in the ag_catalog and is used to create a graph and accepts the name of the graph you want to create as a parameter.
Another function we will be using will be the Cypher function used for constructing cypher queries.
Now with the SELECT * FROM cypher command we have created a vertice with name and title properties:
So Far, So Good!
Similarly, we have created an addtional two more for two more characters:
Alright now let's create a relationship between the two vertices. We will make Master Chief a "LOVER_OF" Cortana cause let's face it we all know that is what they really are. We will do it as follows:
And there you have it. Now for bonus points, if you have Apache AGE-Viewer installed then you can visualized what you have created as follows:
Top comments (0)