<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Zahid</title>
    <description>The latest articles on DEV Community by Muhammad Zahid (@zahid07).</description>
    <link>https://dev.to/zahid07</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1020633%2F1c97e0b7-2fcf-457e-9b32-8c888f151887.png</url>
      <title>DEV Community: Muhammad Zahid</title>
      <link>https://dev.to/zahid07</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zahid07"/>
    <language>en</language>
    <item>
      <title>Starting Out With Apache AGE</title>
      <dc:creator>Muhammad Zahid</dc:creator>
      <pubDate>Sun, 05 Feb 2023 07:03:17 +0000</pubDate>
      <link>https://dev.to/zahid07/starting-out-with-apache-age-4cef</link>
      <guid>https://dev.to/zahid07/starting-out-with-apache-age-4cef</guid>
      <description>&lt;p&gt;Apache AGE is an extension for PostgreSQL that enables users to leverage a graph database on top of the existing relational databases. AGE is an acronym for A Graph Extension and is inspired by Bitnine's AgensGraph, a multi-model database fork of PostgreSQL. The basic principle of the project is to create a single storage that handles both the relational and graph data model so that the users can use the standard ANSI SQL along with openCypher, one of the most popular graph query languages today.&lt;/p&gt;

&lt;p&gt;You can find more info on Apache AGE on their &lt;a href="https://age.apache.org/" rel="noopener noreferrer"&gt;Website&lt;/a&gt; or &lt;a href="https://github.com/apache/age" rel="noopener noreferrer"&gt;Github Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets Start by Creating a New Graph named family_tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT create_graph('family_tree');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this statement we have created an empty graph named family tree. Now lets populate our graph.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM cypher('family_tree', $$ 
CREATE(:Person {
name:'Andrew James',
year_born:1987,
year_died:2020 })
$$) as (person agtype);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our graph family tree we have added a person with the properites: name, year_born and year_died&lt;/p&gt;

&lt;p&gt;Now we would add another person:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM cypher('family_tree', $$ 
CREATE(:Person {
name:'Hannah James',
year_born:1987,
year_died:2020 })
$$) as (person agtype);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our graph family tree we have added a person with the properites: name, year_born and year_died&lt;/p&gt;

&lt;p&gt;Now to Display our data we use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM cypher('family_tree', $$ 
MATCH(v) 
RETURN properties(v) 
$$) as (v agtype);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazr0szsblpi1r0yninad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazr0szsblpi1r0yninad.png" alt="Image description" width="785" height="107"&gt;&lt;/a&gt;&lt;br&gt;
Now Lets add a relationship between these two persons:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; SELECT * from cypher(
'family_tree',
$$
    MATCH (a:Person), (b:Person) WHERE a.name='Andrew James' AND b.name='Hannah James' CREATE (a)-[e:Married_To { from :2010, to:2013}]-&amp;gt;(b) Return e
$$
) as (e agtype);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above command we are adding a relationship between the two persons named Andrew James and Hannah James with named Married_To and with properties: From, To.&lt;/p&gt;

&lt;p&gt;Now to Display the relationship we use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * from cypher(
'family_tree',
$$
    MATCH (a:Person)-[e:Married_To]-(b:Person) Return a.name,label(e),b.name
$$
) as (a agtype, e agtype, b agtype);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kqkr93hmox76pqaa05n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kqkr93hmox76pqaa05n.png" alt="Image description" width="693" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was a simple example to adding vertices and an edge between those vertices.&lt;/p&gt;

</description>
      <category>welcome</category>
    </item>
  </channel>
</rss>
