Chapter 4
Chapter 4
database?
NOSQL CONCEPTS
Miriam Antona
Software engineer
Graph databases - overview
Treat data and its relationships with the same importance
Based on graph theory
branch of mathematics
NOSQL CONCEPTS
Graph databases - parts of a graph
Vertices/nodes
Edges
NOSQL CONCEPTS
Graph databases - parts of a graph
Vertices/nodes
Edges/links/arcs
NOSQL CONCEPTS
Graph databases - nodes
Represent entities (users, cities, airports, employees...)
Have properties
NOSQL CONCEPTS
Graph databases - nodes
Represent entities (users, cities, airports, employees...)
Have properties
NOSQL CONCEPTS
Graph databases - edges
Connect the nodes
Define the relationships between the nodes
NOSQL CONCEPTS
Graph databases - edges
Connect the nodes
Define the relationships between the nodes
NOSQL CONCEPTS
Graph databases - edges
Connect the nodes
NOSQL CONCEPTS
Graph databases - types of edges
Directed:
Specific direction
NOSQL CONCEPTS
Graph databases - types of edges
Undirected:
No direction
NOSQL CONCEPTS
Graph databases - queries
Traversing the graph
Examples:
Get all the users that Ben follows
NOSQL CONCEPTS
Popular graph databases
NOSQL CONCEPTS
Let's practice!
NOSQL CONCEPTS
Advantages and
limitations of graph
databases
NOSQL CONCEPTS
Miriam Antona
Software engineer
Advantages - flexibility
Can change as applications and industries change
Don't need to define the final final structure in advance
NOSQL CONCEPTS
Advantages - performance
Doesn't need to perform joins
Joining can be potentially time-consuming
NOSQL CONCEPTS
Advantages - easy representation of the data
Similar structure to human thinking
Graph modeling very intuitive
Easily visualized
Facilitates understanding
NOSQL CONCEPTS
Advantages - horizontal scalability
It is possible
More difficult than in other NoSQL databases
Graphs are connected
NOSQL CONCEPTS
Limitations
Entity properties with extremely large values
BLOBs (Binary Large Objects): multimedia objects
Bad practice
NOSQL CONCEPTS
Let's practice!
NOSQL CONCEPTS
When to use graph
databases
NOSQL CONCEPTS
Miriam Antona
Software engineer
Suitable cases - General information
Highly connected data
NOSQL CONCEPTS
Suitable cases - Social graphs
Social networks
Users and their relationships
Posts
Likes
...
Employees of a company
Projects
NOSQL CONCEPTS
Suitable cases - Infectious diseases
Model:
Interactions between people
Contact events
Exposures
NOSQL CONCEPTS
Suitable cases - Location services
Locations and distances
Optimize the routes for navigation
applications
cinemas
hospitals
etc.
NOSQL CONCEPTS
Suitable cases - Fraud detection
Stop fraud in real-time:
Credit card fraud
E-commerce fraud
Money laundering
...
NOSQL CONCEPTS
Suitable cases - Real-time recommendations
Store buying history and browsing behavior
to recommend an item
NOSQL CONCEPTS
Suitable cases - Networks
Storage of relationships between networks
and infrastructure elements
physical machines
virtual machines
applications
routers
switches
...
NOSQL CONCEPTS
Unsuitable cases
Disconnected data
Relationships between the data are not important
Applications that only perform general searches without a specific starting point
Are not optimized for those queries
NOSQL CONCEPTS
Let's practice!
NOSQL CONCEPTS
Neo4j case study
NOSQL CONCEPTS
Miriam Antona
Software engineer
Neo4j - overview
Leader in graph database technology
420+ employees
NOSQL CONCEPTS
Neo4j graph platform
Suite of applications and tools
Interact and use graph data
NOSQL CONCEPTS
Neo4j graph platform - Graph database
NOSQL CONCEPTS
Neo4j graph platform - Graph data science library
Used for executing graph algorithms:
Path finding
Centrality
Community detection
Similarity
Link prediction
Node embeddings
Node classification
NOSQL CONCEPTS
Neo4j graph platform - Bloom
NOSQL CONCEPTS
Neo4j graph platform - Cypher
Powerful query language
Inspired by SQL
NOSQL CONCEPTS
Neo4j graph platform - Connectors and Integrations
Facilitate the use of Neo4j in existing architectures
Neo4j Connector for Apache Spark
NOSQL CONCEPTS
Neo4j graph platform - Developer tools
Neo4j Desktop
Local Neo4j databases
Neo4j Browser
Interact with the graphs using a browser
Neo4j Sandbox
Learn about Neo4j, test personal ideas...
NOSQL CONCEPTS
Neo4j graph platform - Aura
Cloud Database Service
Run in the cloud without managing the
infrastructure
NOSQL CONCEPTS
Neo4j - drivers
Official drivers: C#, Java, Python, JavaScript, Spring...
Community drivers: R, PHP, Ruby...
NOSQL CONCEPTS
Neo4j - popular uses
Analytics and artificial intelligence
Fraud detection
Real-time recommendations
Knowledge graphs
Life sciences
Telecommunications
...
NOSQL CONCEPTS
Neo4j - customers
NOSQL CONCEPTS
Gousto - overview
Recipe box company
Delivers over a million meals each month
400+ staff
NOSQL CONCEPTS
Gousto - problem and solution
Problem: More choice implied difficulty to navigate
Solution: Use Neo4j
Internal recommendation system with recipes
subscriber's previous interactions with the menu
NOSQL CONCEPTS
Gousto - results
30% increase in the number of customers that select recommended recipes
NOSQL CONCEPTS
Gousto - results
30% increase in the number of customers that select recommended recipes
1 https://neo4j.com/case-studies/
NOSQL CONCEPTS
Let's practice!
NOSQL CONCEPTS
Congratulations!
NOSQL CONCEPTS
Miriam Antona
Software engineer
Chapter 1
Differences between NoSQL and relational databases
Main concepts of key-value databases
Advantages
simplicity
horizontal scalability
flexibility
Limitations
no complex queries
NOSQL CONCEPTS
Chapter 1
Suitable cases
user-session information
shopping carts
...
Unsuitable cases
search a key based on its value
higher performance
NOSQL CONCEPTS
Chapter 2
Basics of document databases
Advantages
flexibility
horizontal scalability
Limitations
care about the code
NOSQL CONCEPTS
Chapter 2
Suitable cases
catalogs
event logging
user profiles
etc.
Unsuitable cases
very structured data
NOSQL CONCEPTS
Chapter 3
Basics of column family databases
Advantages
flexibility
speed
horizontal scalability
Limitations
no multirow transactions
no joins
no subqueries
NOSQL CONCEPTS
Chapter 3
Suitable scenarios
event logging
time-series data
Unsuitable scenarios
need to change the queries very often
NOSQL CONCEPTS
Chapter 4
Main concepts of graph databases
Advantages
flexibility
high performance
horizontal scalability
Limitations
extremely large objects (BLOBs, CLOBs...)
NOSQL CONCEPTS
Chapter 4
Suitable situations
social graphs
infectious diseases
fraud detection
location services
etc.
Unsuitable situations
disconnected data
etc.
NOSQL CONCEPTS
Chapter 4
Case study: Gousto and Neo4j
better cost control
NOSQL CONCEPTS
Thank you!
NOSQL CONCEPTS