Learn how to enhance your application by using Neo4j and MongoDB together. Polyglot persistence is the concept of taking advantage of the strengths of different database technologies to improve functionality and enhance your application. In this webinar we will examine some use cases where it makes sense to use a document database (MongoDB) with a graph database (Neo4j) in a single application. Specifically, we will show how MongoDB can be used to provide search and browsing functionality for a product catalog while using Neo4j to provide personalized product recommendations. Finally we will look at the Neo4j Doc Manager project which facilitates syncing data from MongoDB to Neo4j to make polyglot persistence with MongoDB and Neo4j much easier.
12. MongoDB
Features
• NoSQL database
• Document datamodel
• JSON-like documents (BSON)
• Flexible data model
• Horizontal scalability (sharding)
• Complex queries
{
"session": {
"title": "12 Years of Spring: An Open Source Journey",
"abstract": "Spring emerged as a core open source project in early 2003 and
evolved to a broad portfolio of open source projects up until 2015."
},
"topics": [
"keynote",
"spring"
],
"room": "Auditorium",
"timeslot": "Wed 29th, 09:30-10:30",
"speaker": {
"name": "Juergen Hoeller",
"bio": "Juergen Hoeller is co-founder of the Spring Framework open source
project.",
"twitter": "https://twitter.com/springjuergen",
"picture": "http://www.springio.net/wp-content/uploads/2014/11/
juergen_hoeller-220x220.jpeg"
}
}
13. MongoDB
Use Cases
• Product catalog
• User profiles
• Metadata
• Content
• Events
• Analytics
{
"session": {
"title": "12 Years of Spring: An Open Source Journey",
"abstract": "Spring emerged as a core open source project in early 2003 and
evolved to a broad portfolio of open source projects up until 2015."
},
"topics": [
"keynote",
"spring"
],
"room": "Auditorium",
"timeslot": "Wed 29th, 09:30-10:30",
"speaker": {
"name": "Juergen Hoeller",
"bio": "Juergen Hoeller is co-founder of the Spring Framework open source
project.",
"twitter": "https://twitter.com/springjuergen",
"picture": "http://www.springio.net/wp-content/uploads/2014/11/
juergen_hoeller-220x220.jpeg"
}
}
https://www.mongodb.com/use-cases/
14. MongoDB
Use Cases
• Product catalog
• User profiles
• Metadata
• Content
• Events
• Analytics
{
"session": {
"title": "12 Years of Spring: An Open Source Journey",
"abstract": "Spring emerged as a core open source project in early 2003 and
evolved to a broad portfolio of open source projects up until 2015."
},
"topics": [
"keynote",
"spring"
],
"room": "Auditorium",
"timeslot": "Wed 29th, 09:30-10:30",
"speaker": {
"name": "Juergen Hoeller",
"bio": "Juergen Hoeller is co-founder of the Spring Framework open source
project.",
"twitter": "https://twitter.com/springjuergen",
"picture": "http://www.springio.net/wp-content/uploads/2014/11/
juergen_hoeller-220x220.jpeg"
}
}
https://www.mongodb.com/use-cases/
15. Neo4j
Graph Database
• Property graph data model
• Nodes and relationships
• Native graph processing
• Cypher query language
16. Property Graph Model Components
Nodes
• The objects in the graph
• Can have name-value properties
• Can be labeled
Relationships
• Relate nodes by type and
direction
• Can have name-value properties
CAR
DRIVES
name: “Dan”
born: May 29, 1970
twitter: “@dan”
name: “Ann”
born: Dec 5, 1975
since:
Jan 10, 2011
brand: “Volvo”
model: “V70”
LOVES
LOVES
LIVES WITH
OW
NS
PERSON PERSON
17. Cypher: SQL for graphs
CREATE (:Person { name:“Dan”} ) -[:LOVES]-> (:Person { name:“Ann”} )
LOVES
Dan Ann
LABEL PROPERTY
NODE NODE
LABEL PROPERTY
18. NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
19. NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
GRAPH THINKING:
Real Time Recommendations
VIEWED
VIEWED
BOUGHT
VIEWED
BOUGHT
BOUGHT
BOUGHT
BOUGHT
20. NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
GRAPH THINKING:
Master Data Management
MANAGES
MANAGES
LEADS
REGION
M
ANAG
ES
MANAGES
REGION
LEADS
LEADS
COLLABORATES
21. NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
GRAPH THINKING:
Fraud Detection
O
PENED_ACCO
UNT
HAS
IS_ISSUED
HAS
LIVES
LIVES
IS_ISSUED
OPENED_ACCOUNT
22. GRAPH THINKING:
Graph Based Search
NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
PUBLISH
INCLUDE
INCLUDE
CREATE
CAPTURE
IN
IN
SOURCE
USES
USES
IN
IN
USES
SOURCE
SOURCE
23. NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
BROWSES
CONNECTS
BRIDGES
ROUTES
POWERS
ROUTES
POWERS
POWERS
HOSTS
QUERIES
GRAPH THINKING:
Network & IT-Operations
24. GRAPH THINKING:
Identity And Access Management
NEO4J USE CASES
Real Time Recommendations
Master Data Management
Fraud Detection
Identity & Access Management
Graph Based Search
Network & IT-Operations
TRUSTS
TRUSTS
ID
ID
AUTHENTICATES
AUTHENTICATES
O
W
NS
OWNS
CAN_READ
34. SYSTEMS OF RECORD
Relational Database Model
Structured
Pre-computed
Based on rigid rules
SYSTEMS OF ENGAGEMENT
NoSQL Database Model
Highly Flexible
Real-Time Queries
Highly Contextual
38. Polyglot Persistence
• Different types of data in different ways
• Take advantage of strengths of different databases
http://martinfowler.com/bliki/PolyglotPersistence.html
39. Polyglot Persistence
Functionality Database type
Shopping Cart Rapid session
reads / writes
Key-value store
Orders / Product
Catalog
Frequent reads Document
Customer social
graph
Recommendation Graph
http://www.jamesserra.com/archive/2015/07/what-is-polyglot-persistence/
59. Java Stored Procedures
User-defined procedures are written in Java,
deployed into the database, and called from Cypher.
http://neo4j.com/docs/developer-manual/current/#procedures
78. Document to property graph
{
"session": {
"title": "12 Years of Spring: An Open Source Journey",
"abstract": "Spring emerged as a core open source
project in early 2003 and evolved to a broad portfolio of
open source projects up until 2015."
},
"topics": [
"keynote",
"spring"
],
"room": "Auditorium",
"timeslot": "Wed 29th, 09:30-10:30",
"speaker": {
"name": "Juergen Hoeller",
"bio": "Juergen Hoeller is co-founder of the Spring
Framework open source project.",
"twitter": "https://twitter.com/springjuergen",
"picture": "http://www.springio.net/wp-content/
uploads/2014/11/juergen_hoeller-220x220.jpeg"
}
}
79. {
"session": {
"title": "12 Years of Spring: An Open Source Journey",
"abstract": "Spring emerged as a core open source
project in early 2003 and evolved to a broad portfolio of
open source projects up until 2015."
},
"topics": [
"keynote",
"spring"
],
"room": "Auditorium",
"timeslot": "Wed 29th, 09:30-10:30",
"speaker": {
"name": "Juergen Hoeller",
"bio": "Juergen Hoeller is co-founder of the Spring
Framework open source project.",
"twitter": "https://twitter.com/springjuergen",
"picture": "http://www.springio.net/wp-content/
uploads/2014/11/juergen_hoeller-220x220.jpeg"
}
}
Document to property graph
82. Using Data Relationships for
Recommendations
Content-based filtering
Recommend items based on what
users have liked in the past
Collaborative filtering
Predict what users like based on the
similarity of their behaviors,
activities and preferences to others
Movie
Person
Person
RATED
SIMILARITY
rating: 7
value: .92