SlideShare a Scribd company logo
Relational DB
vs
Document (no-SQL) DB
vs
Graph DB
Explanation through Examples
Relational DB
 This example has one to one
mapping.
 Foreign key reference.
 Normalized Structure, no
redundancy.
 Unique identifier necessary for
primary key as well as foreign key.
Article ID Article Name Article Content Article Date Author ID
ar1 Some Article Some Content 20-Feb-2010 au1
ar2 Other Article Other Content 10-Nov-2019 au2
ar3 Another Article Another Content 15-Sep-2011 au2
Author ID Author Name Author DOB
au1 Classy Betty 03-Jan-1970
au2 Casual Sam 04-Mar-1960
Document DB (no-SQL)
 The same example from previous
slide is designed with one level
nesting in this structure.
 Author structures nested in Article
structures.
 Redundancy in author information,
but that is normal in view of faster
access.
 Unlike relational DB, unique
identifier not needed.
 Usually represented as JSON
structure (illustrated to the right) or
key-value store (illustrated in a later
slide).
[
{
"Article Name": "Some Article",
"Article Content": "Some Content",
"Article Date": "20-Feb-2010",
"Author": {
"Author Name": "Classy Betty",
"Author DOB": "03-Jan-1970"
}
},
{
"Article Name": "Other Article",
"Article Content": "Other Content",
"Article Date": "10-Nov-2019",
"Author": {
"Author Name": "Casual Sam",
"Author DOB": "04-Mar-1960"
}
},
{
"Article Name": "Another Article",
"Article Content": "Another Content",
"Article Date": "15-Sep-2011",
"Author": {
"Author Name": "Casual Sam",
"Author DOB": "04-Mar-1960"
}
}
]
Graph DB
 This example has one to one
mapping, explained as relations.
 Normalized Structure, no
redundancy.
 Graph consists of nodes and
relationship.
 Both nodes and relationship can
have additional properties.
Type Command
Articles
(Node)
CREATE
(ar1:Article {name:'Some Article',content:"Some Content",date:"20-Feb-2010"})
CREATE
(ar2:Article {name:'Other Article',content:"Other Content",date:"10-Nov-2019"})
CREATE
(ar3:Article {name:'Another Article',content:"Another Content",date:"15-Sep-2011"})
Authors
(Node)
CREATE (au1:Author {name:'Classy Betty',dob:'03-Jan-1970'})
CREATE (au2:Author {name:'Casual Sam',dob:'04-Mar-1960'})
Authored By
(Relationship)
CREATE (ar1)-[:AUTHORED_BY]->(au1)
CREATE (ar2)-[:AUTHORED_BY]->(au2)
CREATE (ar3)-[:AUTHORED_BY]->(au2)
Relational DB
 This example has many to many
relationship.
 Foreign key reference in a separate
mapping table.
 Normalized Structure, no
redundancy.
 Unique identifier necessary for
primary key as well as foreign key.
Article ID Article Name Article Content Article Date
ar1 Some Article Some Content 20-Feb-2010
ar2 Other Article Other Content 10-Nov-2019
ar3 Another Article Another Content 15-Sep-2011
Author ID Author Name Author DOB
au1 Classy Betty 03-Jan-1970
au2 Casual Sam 04-Mar-1960
Author ID Article ID
au1 ar1
au2 ar1
au2 ar2
au1 ar3
au2 ar3
Document DB (no-SQL)
 The same example from previous
slide is designed with one level
nesting in this structure.
 The structure shows Author
structures nested in Article
structures.
 Redundancy in author information,
but that is normal in view of faster
access.
 The nested modelling is predefined
in view of the consumer application.
 Unlike relational DB, unique
identifier not needed.
Articles Collection (Authors nested within documents)
0 Article Name Some Article
Article Content Some Content
Article Date 20-Feb-2010
Authors 0 Author Name Classy Betty
Author DOB 03-Jan-1970
1 Author Name Casual Sam
Author DOB 04-Mar-1960
1 Article Name Other Article
Article Content Other Content
Article Date 10-Nov-2019
Authors 0 Author Name Casual Sam
Author DOB 04-Mar-1960
2 Article Name Another Article
Article Content Another Content
Article Date 15-Sep-2011
Authors 0 Author Name Classy Betty
Author DOB 03-Jan-1970
1 Author Name Casual Sam
Author DOB 04-Mar-1960
Document DB (no-SQL)
 The same example from previous
slide is designed with one level
nesting in this structure.
 The structure shows Article
structures nested in Author
structures.
 Redundancy in article information,
but that is normal in view of faster
access.
 The nested modelling is predefined
in view of the consumer application.
 Unlike relational DB, unique
identifier not needed.
Authors Collection (Articles nested within documents)
0 Author Name Classy Betty
Author DOB 03-Jan-1970
Articles 0 Article Name Some Article
Article Content Some Content
Article Date 20-Feb-2010
1 Article Name Another Article
Article Content Another Content
Article Date 15-Sep-2011
1 Author Name Casual Sam
Author DOB 04-Mar-1960
Articles 0 Article Name Some Article
Article Content Some Content
Article Date 20-Feb-2010
1 Article Name Other Article
Article Content Other Content
Article Date 10-Nov-2019
2 Article Name Another Article
Article Content Another Content
Article Date 15-Sep-2011
Document DB (no-SQL)
 The same example from previous
slide is designed in JSON structure
following the two modelling
approaches (partially displayed).
[
{
"Article Name": "Some Article",
"Article Content": "Some Content",
"Article Date": "20-Feb-2010",
"Authors": [
{
"Author Name": "Classy Betty",
"Author DOB": "03-Jan-1970"
},
{
"Author Name": "Casual Sam",
"Author DOB": "04-Mar-1960"
}
]
},
{
"Article Name": "Other Article",
"Article Content": "Other Content",
"Article Date": "10-Nov-2019",
"Authors": [
{
"Author Name": "Casual Sam",
"Author DOB": "04-Mar-1960"
}
]
},
…………………………….
]
[
{
"Author Name": "Classy Betty",
"Author DOB": "03-Jan-1970",
"Articles": [
{
"Article Name": "Some Article",
"Article Content": "Some Content",
"Article Date": "20-Feb-2010"
},
{
"Article Name": "Another Article",
"Article Content": "Another Content",
"Article Date": "15-Sep-2011"
}
]
},
{
"Author Name": "Casual Sam",
"Author DOB": "04-Mar-1960",
"Articles": [
{
"Article Name": "Some Article",
"Article Content": "Some Content",
"Article Date": "20-Feb-2010"
},
…………………………….
]
}
]
Graph DB
 This example has many to many
mapping, explained as relations.
 Normalized Structure, no
redundancy.
 Graph consists of nodes and
relationship.
 Both nodes and relationship can
have additional properties.
Type Command
Articles
(Node)
CREATE
(ar1:Article {name:'Some Article',content:"Some Content",date:"20-Feb-2010"})
CREATE
(ar2:Article {name:'Other Article',content:"Other Content",date:"10-Nov-2019"})
CREATE
(ar3:Article {name:'Another Article',content:"Another Content",date:"15-Sep-2011"})
Authors
(Node)
CREATE (au1:Author {name:'Classy Betty',dob:'03-Jan-1970'})
CREATE (au2:Author {name:'Casual Sam',dob:'04-Mar-1960'})
Authored By
(Relationship)
CREATE (ar1)-[:AUTHORED_BY]->(au1)
CREATE (ar1)-[:AUTHORED_BY]->(au2)
CREATE (ar2)-[:AUTHORED_BY]->(au2)
CREATE (ar3)-[:AUTHORED_BY]->(au1)
CREATE (ar3)-[:AUTHORED_BY]->(au2)

More Related Content

PPTX
Document databases
PPTX
Module 2.3 Document Databases in NoSQL Systems
PDF
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
PDF
Schema Design
PPTX
Webinar: Schema Design
PPTX
Schema design mongo_boston
PPTX
Schema Design
PPTX
Modeling JSON data for NoSQL document databases
Document databases
Module 2.3 Document Databases in NoSQL Systems
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
Schema Design
Webinar: Schema Design
Schema design mongo_boston
Schema Design
Modeling JSON data for NoSQL document databases

Similar to Comparing databases with examples (20)

PPTX
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
PPTX
Azure Database Options - NoSql vs Sql
PPTX
Dev Jumpstart: Schema Design Best Practices
PPTX
Schema Design
PPTX
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
PPTX
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
PDF
Relationships are hard
PDF
Schema Design
PDF
Data Modeling with Neo4j
PDF
Schema & Design
KEY
Modeling Data in MongoDB
ODP
No More SQL
PPTX
Presentation: mongo db & elasticsearch & membase
PPTX
Webinar: Schema Design
PPTX
No sq lv2
PDF
Schema Design
PPTX
Azure DocumentDB: Advanced Features for Large Scale-Apps
PDF
01_Chapter_Introducing Data Modeling.pdf
PDF
01_Chapter_Introducing Data Modeling.pdf
PDF
Nosql part1 8th December
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
Azure Database Options - NoSql vs Sql
Dev Jumpstart: Schema Design Best Practices
Schema Design
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
MongoDB San Francisco 2013: Schema design presented by Jason Zucchetto, Consu...
Relationships are hard
Schema Design
Data Modeling with Neo4j
Schema & Design
Modeling Data in MongoDB
No More SQL
Presentation: mongo db & elasticsearch & membase
Webinar: Schema Design
No sq lv2
Schema Design
Azure DocumentDB: Advanced Features for Large Scale-Apps
01_Chapter_Introducing Data Modeling.pdf
01_Chapter_Introducing Data Modeling.pdf
Nosql part1 8th December
Ad

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
L1 - Introduction to python Backend.pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Illustrator 28.6 Crack My Vision of Vector Design
VVF-Customer-Presentation2025-Ver1.9.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PTS Company Brochure 2025 (1).pdf.......
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Reimagine Home Health with the Power of Agentic AI​
2025 Textile ERP Trends: SAP, Odoo & Oracle
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
wealthsignaloriginal-com-DS-text-... (1).pdf
Operating system designcfffgfgggggggvggggggggg
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
Upgrade and Innovation Strategies for SAP ERP Customers
Ad

Comparing databases with examples

  • 1. Relational DB vs Document (no-SQL) DB vs Graph DB Explanation through Examples
  • 2. Relational DB  This example has one to one mapping.  Foreign key reference.  Normalized Structure, no redundancy.  Unique identifier necessary for primary key as well as foreign key. Article ID Article Name Article Content Article Date Author ID ar1 Some Article Some Content 20-Feb-2010 au1 ar2 Other Article Other Content 10-Nov-2019 au2 ar3 Another Article Another Content 15-Sep-2011 au2 Author ID Author Name Author DOB au1 Classy Betty 03-Jan-1970 au2 Casual Sam 04-Mar-1960
  • 3. Document DB (no-SQL)  The same example from previous slide is designed with one level nesting in this structure.  Author structures nested in Article structures.  Redundancy in author information, but that is normal in view of faster access.  Unlike relational DB, unique identifier not needed.  Usually represented as JSON structure (illustrated to the right) or key-value store (illustrated in a later slide). [ { "Article Name": "Some Article", "Article Content": "Some Content", "Article Date": "20-Feb-2010", "Author": { "Author Name": "Classy Betty", "Author DOB": "03-Jan-1970" } }, { "Article Name": "Other Article", "Article Content": "Other Content", "Article Date": "10-Nov-2019", "Author": { "Author Name": "Casual Sam", "Author DOB": "04-Mar-1960" } }, { "Article Name": "Another Article", "Article Content": "Another Content", "Article Date": "15-Sep-2011", "Author": { "Author Name": "Casual Sam", "Author DOB": "04-Mar-1960" } } ]
  • 4. Graph DB  This example has one to one mapping, explained as relations.  Normalized Structure, no redundancy.  Graph consists of nodes and relationship.  Both nodes and relationship can have additional properties. Type Command Articles (Node) CREATE (ar1:Article {name:'Some Article',content:"Some Content",date:"20-Feb-2010"}) CREATE (ar2:Article {name:'Other Article',content:"Other Content",date:"10-Nov-2019"}) CREATE (ar3:Article {name:'Another Article',content:"Another Content",date:"15-Sep-2011"}) Authors (Node) CREATE (au1:Author {name:'Classy Betty',dob:'03-Jan-1970'}) CREATE (au2:Author {name:'Casual Sam',dob:'04-Mar-1960'}) Authored By (Relationship) CREATE (ar1)-[:AUTHORED_BY]->(au1) CREATE (ar2)-[:AUTHORED_BY]->(au2) CREATE (ar3)-[:AUTHORED_BY]->(au2)
  • 5. Relational DB  This example has many to many relationship.  Foreign key reference in a separate mapping table.  Normalized Structure, no redundancy.  Unique identifier necessary for primary key as well as foreign key. Article ID Article Name Article Content Article Date ar1 Some Article Some Content 20-Feb-2010 ar2 Other Article Other Content 10-Nov-2019 ar3 Another Article Another Content 15-Sep-2011 Author ID Author Name Author DOB au1 Classy Betty 03-Jan-1970 au2 Casual Sam 04-Mar-1960 Author ID Article ID au1 ar1 au2 ar1 au2 ar2 au1 ar3 au2 ar3
  • 6. Document DB (no-SQL)  The same example from previous slide is designed with one level nesting in this structure.  The structure shows Author structures nested in Article structures.  Redundancy in author information, but that is normal in view of faster access.  The nested modelling is predefined in view of the consumer application.  Unlike relational DB, unique identifier not needed. Articles Collection (Authors nested within documents) 0 Article Name Some Article Article Content Some Content Article Date 20-Feb-2010 Authors 0 Author Name Classy Betty Author DOB 03-Jan-1970 1 Author Name Casual Sam Author DOB 04-Mar-1960 1 Article Name Other Article Article Content Other Content Article Date 10-Nov-2019 Authors 0 Author Name Casual Sam Author DOB 04-Mar-1960 2 Article Name Another Article Article Content Another Content Article Date 15-Sep-2011 Authors 0 Author Name Classy Betty Author DOB 03-Jan-1970 1 Author Name Casual Sam Author DOB 04-Mar-1960
  • 7. Document DB (no-SQL)  The same example from previous slide is designed with one level nesting in this structure.  The structure shows Article structures nested in Author structures.  Redundancy in article information, but that is normal in view of faster access.  The nested modelling is predefined in view of the consumer application.  Unlike relational DB, unique identifier not needed. Authors Collection (Articles nested within documents) 0 Author Name Classy Betty Author DOB 03-Jan-1970 Articles 0 Article Name Some Article Article Content Some Content Article Date 20-Feb-2010 1 Article Name Another Article Article Content Another Content Article Date 15-Sep-2011 1 Author Name Casual Sam Author DOB 04-Mar-1960 Articles 0 Article Name Some Article Article Content Some Content Article Date 20-Feb-2010 1 Article Name Other Article Article Content Other Content Article Date 10-Nov-2019 2 Article Name Another Article Article Content Another Content Article Date 15-Sep-2011
  • 8. Document DB (no-SQL)  The same example from previous slide is designed in JSON structure following the two modelling approaches (partially displayed). [ { "Article Name": "Some Article", "Article Content": "Some Content", "Article Date": "20-Feb-2010", "Authors": [ { "Author Name": "Classy Betty", "Author DOB": "03-Jan-1970" }, { "Author Name": "Casual Sam", "Author DOB": "04-Mar-1960" } ] }, { "Article Name": "Other Article", "Article Content": "Other Content", "Article Date": "10-Nov-2019", "Authors": [ { "Author Name": "Casual Sam", "Author DOB": "04-Mar-1960" } ] }, ……………………………. ] [ { "Author Name": "Classy Betty", "Author DOB": "03-Jan-1970", "Articles": [ { "Article Name": "Some Article", "Article Content": "Some Content", "Article Date": "20-Feb-2010" }, { "Article Name": "Another Article", "Article Content": "Another Content", "Article Date": "15-Sep-2011" } ] }, { "Author Name": "Casual Sam", "Author DOB": "04-Mar-1960", "Articles": [ { "Article Name": "Some Article", "Article Content": "Some Content", "Article Date": "20-Feb-2010" }, ……………………………. ] } ]
  • 9. Graph DB  This example has many to many mapping, explained as relations.  Normalized Structure, no redundancy.  Graph consists of nodes and relationship.  Both nodes and relationship can have additional properties. Type Command Articles (Node) CREATE (ar1:Article {name:'Some Article',content:"Some Content",date:"20-Feb-2010"}) CREATE (ar2:Article {name:'Other Article',content:"Other Content",date:"10-Nov-2019"}) CREATE (ar3:Article {name:'Another Article',content:"Another Content",date:"15-Sep-2011"}) Authors (Node) CREATE (au1:Author {name:'Classy Betty',dob:'03-Jan-1970'}) CREATE (au2:Author {name:'Casual Sam',dob:'04-Mar-1960'}) Authored By (Relationship) CREATE (ar1)-[:AUTHORED_BY]->(au1) CREATE (ar1)-[:AUTHORED_BY]->(au2) CREATE (ar2)-[:AUTHORED_BY]->(au2) CREATE (ar3)-[:AUTHORED_BY]->(au1) CREATE (ar3)-[:AUTHORED_BY]->(au2)