DEV Community

Cover image for About graph databases

Posted on


About graph databases

Hi, lets talk about graph databases.😊 A graph database is composed of two elements: nodes (vertices) and relationships (edges). A node is comparable to an entity in relational databases, the relationships connect the nodes. Properties are similar to attributes of a relational database, they are key-value pairs that can be stored on both nodes and relationships.

You can add labels to the nodes and relationships to specify their type. The data model of graph databases is called the labeled property graph model. Cypher is the query language for graphs. Here is an example for creating two nodes with a relationship:

CREATE (ee:Person { name: "Emil", from: "Sweden"})–[:WORKS_FOR]->(:Company {name: ”Google”})

It is a CREATE clause to create data.

  • () parenthesis to indicate a node
  • ee:Person: a variable 'ee' and label 'Person' for the new node
  • {} brackets to add properties to the node
  • [:WORKS_FOR]→ specifies the relationship to the Company node.

If you now want to retrieve these nodes with their relationship write:

MATCH (ee:Person{name:’Emil’}) –[:WORKS_FOR]->(m) RETURN *;

Neo4J is the most popular graph database managament system at the moment. On their website you can use a sandbox with predefined datasets to play around, on the picture I queried the “Crime Investigation Dataset”. :) They also have a lot of info for beginners, find the link at the end.

What do you know about graph databases? Have a nice evening! :)

Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<