DEV Community

Cover image for Graph databases introduction
Anja
Anja

Posted on

2 1

Graph databases introduction

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”})
Enter fullscreen mode Exit fullscreen mode

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 *;
Enter fullscreen mode Exit fullscreen mode

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! :)
Reference: neo4j.com

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay