Graph database — NoSQL database

ref: https://techcrunch.com/wp-content/uploads/2020/02/cypher_graph_v2a.png?w=1390&crop=1

The third category of NoSQL database that we are going to discuss is graph database.

What is graph database and how is it used?

A graph database uses nodes, edges to represent and store data in a database. The collection of nodes and edges in the graph are data items in store, where the edges represent relationship between nodes. This relationship allows data that is linked together to be fetched with one operation.

Need for graph databases: We live in a connected world and graph database is purposefully built to handle highly connected data. The relationship between items is as important as the item itself. While existing relational databases can store relations, we navigate them by performing expensive joins or cross-lookups. It looks like relational databases are bad in handling relations, but the good news is that graph databases are good in handling relations as no expensive joins or lookups are needed to navigate the relations.

Graph databases can be used to discover hidden connections between distant items and navigate deep hierarchies. Whether it is social network, road network or payment network, everything is interconnected graph of relationships and can be represented using graphs.

Nodes are instances in graph where nodes can hold any number of key-value pairs or properties or meta data. Nodes can be tagged as labels representing their role in the graph.

Edges provide directed, named connection between two entities. Edges always have direction, start node, end node and they can have properties(for ex: person A lives in house since 2016 where person A and house are entities, lives is relationship and since 2016 is property). Any number of relations can exist between instances without affecting performance.

Advantages:

  • Flexibility: Changing the structure and schema of graph database is flexible as company demands change. But in traditional databases, schema modeling is done ahead of time and changing structure of database becomes time-consuming process later on.
  • Real time data update: Graph databases can perform real-time updates while supporting queries simultaneously. In big data management systems, appending and querying is part of workload where any query would touch majority of file, while graph database only touch relevant data.

Disadvantages:

  • Graphs don’t work for transaction-based systems.

Use cases:

  • Connection recommendation system: This is used by major tech giants like facebook, instagram to provide friend recommendation by suggesting connections of a person to every connection as mutual friends.
  • Routing: Information is sent over the internet by finding optimal paths with the help of graph database. Algorithm: shortest path between two nodes — Dijkstra’s and BFS

Best graph databases: Neo4j, ArangoDB, FlockDB

Summary: Graph database provides excellent performance for analyzing complex relationships among entities.There are many more enhancements yet to come in graphs.

The next blog with cover last category of NoSQL database i.e. wide column store.

Thank you for checking out my blog! Subscribe to get notified on upcoming blogs!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SAKSHI CHHABRA

Master's student in Computer Science from University of Florida. I love to write and help others, so here am i.