Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
What is Graph Database - Introduction
Next article icon

What is Graph Database - Introduction

Last Updated : 01 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

What is a Graph Database?

A graph database (GDB) is a database that uses graph structures for storing data. It uses nodes, edges, and properties instead of tables or documents to represent and store data. The edges represent relationships between the nodes. This helps in retrieving data more easily and, in many cases, with one operation. Graph databases are commonly referred to as NoSQL. Ex: Neo4j, Amazon Neptune, ArangoDB etc.

Representation:

The graph database is based on graph theory. The data is stored in the nodes of the graph and the relationship between the data are represented by the edges between the nodes.

graph representation of data

When do we need Graph Database?

1. It solves Many-To-Many relationship problems

If we have friends of friends and stuff like that, these are many to many relationships.
Used when the query in the relational database is very complex.

2. When relationships between data elements are more important

For example- there is a profile and the profile has some specific information in it but the major selling point is the relationship between these different profiles that is how you get connected within a network.
In the same way, if there is data element such as user data element inside a graph database there could be multiple user data elements but the relationship is what is going to be the factor for all these data elements which are stored inside the graph database.

3. Low latency with large scale data

When you add lots of relationships in the relational database, the data sets are going to be huge and when you query it, the complexity is going to be more complex and it is going to be more than a usual time. However, in graph database, it is specifically  designed for this particular purpose and one can query relationship with ease. 


Why do Graph Databases matter? Because graphs are good at handling relationships, some databases store data in the form of a graph. 


Example We have a social network in which five friends are all connected. These friends are Anay, Bhagya, Chaitanya, Dilip, and Erica. A graph database that will store their personal information may look something like this: 

idfirst namelast nameemailphone
1AnayAgarwal[email protected]555-111-5555
2BhagyaKumar[email protected]555-222-5555
3ChaitanyaNayak[email protected]555-333-5555
4DilipJain[email protected]555-444-5555
5EricaEmmanuel[email protected]555-555-5555

Now, we will also a need another table to capture the friendship/relationship between users/friends. Our friendship table will look something like this:

user_idfriend_id
12
13
14
15
21
23
24
25
31
32
34
35
41
42
43
45
51
52
53
54

We will avoid going deep into the Database(primary key & foreign key) theory. Instead just assume that the friendship table uses id's of both the friends. Assume that our social network here has a feature that allows every user to see the personal information of his/her friends. So, If Chaitanya were requesting information then it would mean she needs information about Anay, Bhagya, Dilip and Erica. We will approach this problem the traditional way(Relational database). We must first identify Chaitanya's id in the User's table:

idfirst namelast nameemailphone
3ChaitanyaNayak[email protected]555-333-5555

Now, we'd look for all tuples in friendship table where the user_id is 3. Resulting relation would be something like this:

user_idfriend_id
31
32
34
35

Now, let's analyse the time taken in this Relational database approach. This will be approximately log(N) times where N represents the number of tuples in friendship table or number of relations. Here, the database maintains the rows in the order of id's. So, in general for 'M' no of queries, we have a time complexity of M*log(N) Only if we had used a graph database approach, the total time complexity would have been O(N). Because, once we've located Cindy in the database, we have to take only a single step for finding her friends. Here is how our query would be executed: 
 
 

Advantages: Frequent schema changes, managing  volume of data, real-time query response time, and more intelligent data activation requirements are done by graph model.

Disadvantages: Note that graph databases aren’t always the best solution for an application. We will need to assess the needs of application before deciding the architecture.

Limitations of Graph Databases:

  • Graph Databases may not be offering better choice over the NoSQL variations.
  • If application needs to scale horizontally this may introduces poor performance.
  • Not very efficient when it needs to update all nodes with a given parameter.

Next Article
What is Graph Database - Introduction
https://media.geeksforgeeks.org/auth/avatar.png
GeeksforGeeks
Improve
Article Tags :
  • DBMS

Similar Reads

    Introduction to Graph Database on NoSQL
    A graph database is a type of NoSQL database that is designed to handle data with complex relationships and interconnections. In a graph database, data is stored as nodes and edges, where nodes represent entities and edges represent the relationships between those entities. Graph databases are parti
    8 min read
    Neo4j : The Graph Database
    Neo4j is the most famous database management system and it is also a NoSQL database system. Neo4j is different from Mysql or MongoDB it has its own features and it is designed to efficiently store and query highly interconnected data that's makes it special compared to other Database Management Syst
    5 min read
    Project Idea | Recommendation System based on Graph Database
    The main objective of this project is to build an efficient recommendation engine based on graph database(Neo4j). The system aims to be a one stop destination for recommendations such as Movies, Books, Blog. Features: Movie Module: a) Rate Movies (1-5) rating. b) Get Movie Recommendations using coll
    1 min read
    What is Dispatch and Location-Based Services in Graph-based Database?
    Pre-requisites: Types of NoSQL Databases, Introduction to Graph Database on NoSQL NoSQL systems called graph databases were developed for investigating correlation within intricately connected entities. By emphasizing the data relationship more, the structure addresses the drawbacks of relational da
    3 min read
    Generation of Database Revolutions in NoSQL
    The first generation of database revolutions occurred in the late 1960s and early 1970s when the relational model was first introduced. This was followed by the second generation of database revolutions in the late 1990s and early 2000s when NoSQL databases began to gain popularity. There have been
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences