SlideShare uma empresa Scribd logo
1 de 65
Graph Oriented
Databases
Ciao
ciao
Vai a fare
ciao ciao
Dr. Fabio Fumarola
Outline
• Introduction
• The Lack of relationship for RDBMS and NoSQL
• Graph Databases: Features
• Relations
• Query Language
• Data Modeling with Graphs
• Conclusions
2
Introduction
• We live in a connected world
• Everything is connected: Social Network, Biology,
Bioinformatics
• The NoSQL databases analyzed store data using
aggregate
• Here we compare graph databases with relational
databases and aggregate NOSQL in storing graph
data
3
Three Facts
1. Relational Databases Lack Relationships
1. NoSQL Databases also Lack Relationships
2. Graph Databases Embrace Relationships
4
Relational Databases Lack Relationships
• For decades we tried to accommodate connected,
semi-structured datasets inside relational databases.
• But:
– relational databases are designed to codify tabular
structures
– They struggle when modeling ad hoc exceptional
relationships that are in real world.
5
Relational Databases Lack Relationships
• Relationships in relational database only mean joining tables
• But we want to model the semantic of relationships that
connect real world
• As outlier data multiplies:
1. The structure of the dataset becomes more complex and
less uniform
2. The relational data becomes more complex and less
uniform (large join tables, sparsely populated rows, a lot
o null values)
6
Example of customer-centric orders
• Complex joins
• Foreign key constraints
• Sparse table with null
values
• Reciprocal queries are
costly “What products did a
customer buy?”
7
NoSQL Databases Also Lack
Relationships
• key-value, document, or column-oriented store sets of
disconnected documents/values/columns
• One well-known strategy for adding relationships is to embed
an aggregate’s identifier inside the field belonging to another
aggregate
• But this require joins at the application level
• Some NoSQL have some concept of navigability but it is
expensive for complex joins
8
Example of aggregate oriented orders
• Some properties are
references to foreign
aggregates
• This relationship are
not first-class citizens
• Are not intended as
real realtionships
9
Example of a Small Social Network
• it’s easy to find a user’s
immediate friends
• friendship isn’t always
reflexive
• We can have brute-force
scan across the whole
dataset looking for friends
entries
10
Graph Databases Embrace Relationships
• The previous examples have dealt with implicitly connected
data
• We infer semantic dependencies between entities
• We model the data based on this connections
• Our application have to navigate on this flat and disconnected
data, and deal with slow queries.
• In contrast, in the graph world, connected data is stored as
connected data
11
Example Social Network
12
• The node user:Bob is a
Vertex with a property
Bob
• We also see relations
which are Edges:
• Boss_of
• Friend_of
• Married_to
GRaph DB Features
13
CAP Theorem
14
Consistency
• Since Graph DBs operate on connected nodes, they
could not scale well distributing nodes across
servers.
• There are solutions supporting distribution:
– Neo4j uses one master and several slaves
– OrientDB uses MVCC for distributed eventual data
structures
– TitanDB partition data by using HBase or Cassandra
15
Transactions
• Most of the Graph DB are ACID-compliant
• Before doing an operation we have to start a
transaction.
• Without wrapping operations in a transaction we will
get an Exception.
16
Availability
• Neo4j from version 1.8 achieves availability by
providing for replicated slaves.
• Infinity Graph, FlockDB and TitanDB provides for
distribute storage of the nodes.
• Neo4J uses Zookeeper to keep track of the last
transaction Ids persisted on each slave node and the
current master node
17
Going Into Relations
18
Relations
• Relations in a graph naturally forms paths.
• Querying or traversing the graph involves following a
path.
• A query on the graph is also known as traversing the
graph
• As advantage we can change the traversing
requirements without changing nodes and edges
19
Relations
• In graph databases traversal operation are highly
efficient.
• In the book Neo4j in Action, Partner and Vukotic
perform an experiment comparing relational store
and Neo4j
20
Relations
• In a depth two (friend-of-friend), both relational db and graph
db perform well enough
• But when we do the depth three it clear that relational db can
no longer deal
21
Relations
• Both aggregate store and relational databases perform poorly
because of the index lookups.
• Graphs, on the other hand, use index-free adjacency list to
ensure that traversing connected data is extremely fast.
22
Relations another case study
• Let us consider the
purchase history of a user
as connected data.
• If we notice that users who
buy strawberry ice cream
also buy espresso beans, we
can start to recommend
those beans to users who
normally only buy the ice
cream.
23
Relations and Recommendations
• The previous was a one dimensional
recommendation
• We can join our graph with graph from other
domains.
• For example, we can ask to fine
– “all the flavors of ice cream liked by people who live near a
user, and enjoy espresso, but dislike Brussels sprouts.”
24
Relations and Patterns
• We can use relations to query graph-patterns
• Such pattern-matching queries are:
– extremely difficult to write in SQL
– And are laborious to write against aggregate stores
• In both cases they tend to perform very poorly
• In the other hand, graph databases are optimized for
such kind of queries
25
Query Language
26
Query Language
• Graph DBs support query
languages such as Gremlin,
Cypher and SPARQL
• Gremlin is a DSL for
traversing graphs;
• It can traverse all the graph
databases implementing the
Blueprints
27
1. Indexing: Nodes and Edges
• Indexes are necessary to find the starting node to
being traversal.
• How Indexes works:
– Can index properties of nodes and edges.
– Adds are done in transactions
• Nodes retrieved can be used to raise queries
28
2. Querying In- Out- Relationships
• Having a node we can query both for Incoming and
Outgoing relationships.
• We can apply directional filters on the queries when
querying for relations
29
3. Querying Breadth- Depth-
• Graph databases are really powerful to query for
incoming and outgoing relationships.
• Moreover, we can make the traverser go top-down
or sideways on the graph by using:
– BREADTH_FIRST or
– DEPTH_FIRST
30
4. Querying Paths
• An other good feature of graph databases is
– finding paths between two nodes.
– Determining if there are multiple paths
– finding the shortest path
• Many Graph DBs use algorithms such as the
Dijkstra’s algorithm for finding shortest paths.
31
5. Querying Paths
• Finally, with Graph DBs it is possible to use Match
operator
• The MATCH is used for matching patterns in
relationships
• The WHERE filters the properties on a node or
relationship
• The RETURN specifies what to get in the result set.
32
Data Modeling with Graphs
Intro
33
Data Modeling with Graphs
how do we model the world in graph terms?
34
how do we model the world in
graph terms?
• Formalization of the base model
• Enrich the model
• Testing the model
35
Formalization of the base model
• Modeling is an abstracting activity motivated by a particular
need or goal
• We model in order to define structures that can manipulated.
• There are no natural representations of the world the way it
“really is,”
• There are just many purposeful selections, abstractions, and
simplifications that useful for satisfying a particular goal
36
Formalization of the base model
• Graph data modeling is different from many other
techniques.
• There is a close affinity between logical and physical
models.
• In relational databases we start from a logical model
to arrive to the physical model.
• With graph databases, this gap shrinks considerably.
37
The Graph Model
• A property graph is made up of nodes, relationships,
and properties.
38
Publishing Messages
• We organize messages in order
39
Nodes
Nodes contain properties
•Think of nodes as documents that store properties in
the form of arbitrary key-value pairs.
•The keys are strings and the values are arbitrary data
types.
40
Relationships
Relationships connect and structure nodes.
•A relationship always has a direction, a label, and a
start node and an end node—there are no dangling
relationships.
•Together, a relationship’s direction and label add
semantic clarity to the structuring of nodes.
41
Relationships: Attributes
Like nodes, relationships can also have properties.
•The ability to add properties to relationships is
particularly useful for:
– Providing additional metadata for graph algorithms
– Adding additional semantics to relationships (including
quality and weight),
– and for constraining queries at runtime.
42
Modeling Steps: Outline
• The initial stage of modeling is similar to the first
stage of many other data modeling techniques, that
is:
– to understand and agree on the entities in the domain
– how they interrelate
– and the rules that govern their state transitions
43
Describe the Model in Terms of the
Application’s Needs
• Agile user stories provide a concise means for
expressing an outside-in, user-centered view of the
application needs.
• Here’s an example of a user story for a book review
web application:
– AS A reader who likes a book,
– I WANT to know which books other readers who like the
same book have liked,
– SO THAT I can find other books to read.
44
Describe the Model in Terms of the
Application’s Needs
• This story expresses a user need, which motivates
the shape and content of our data model.
• From a data modeling point of view:
– the AS A clause establishes a context comprising two
entities—a reader and a book—plus the LIKES relationship
that connects them.
– The I WANT clause exposes more LIKES relationships, and
more entities: other readers and other books.
45
Describe the Model in Terms of the
Application’s Needs
• The entities and relationships in analyzing the user
story quickly translate into a simple data model
46
Modeling Rationale
• Use nodes to represent entities
• Use relationships both:
– to express the connections between entities and
– to establish semantic context for each entity
• Use relationship direction to further clarify
relationship semantics
47
Describe the Model: Guidelines
• Use node properties
– to represent entity attributes, plus any necessary entity
metadata, such as timestamps, version numbers, etc
• Use relationship properties
– to express the strength, weight, or quality of a
relationship, plus any necessary relationship metadata,
such as timestamps, version numbers, etc.
48
Modeling Temporal Relations as
Nodes
• When two or more domain entities interact for a
period of time, a fact emerges
• We represent these facts as separate nodes
• In the following examples we show how we might
model facts and actions using intermediate nodes.
49
Example: Employment
Ian was employed as an engineer at Neo Technology
50
Example: Performance
William Hartnell played the Doctor in the story The
Sensorites
51
Example: Emailing
Ian emailed Jim, and copied in Alistair
52
Example:
Timeline Tree
53
A timeline tree showing the broadcast
dates for four episodes of a TV
program
Example: Linked-List
A doubly linked list representing a time-ordered series
of events
54
Iterative and Incremental
• We develop the data model feature by feature, user
story by user story
• This will ensure we identify the relationships our
application will use to query the graph
• With the iterative and incremental delivery of
application features we will be a corrected model
that provides the right abstraction
55
Data Modeling: Enrich
• The next steps diverges from the relational data
methodology
• Instead of transforming a domain model’s graph-like
representation into tables, we enrich it.
• That is, for each entity in our domain, “we ensure
that we’ve captured both the properties and the
connections to neighboring entities necessary to
support our application goals”.
56
Data Modeling: Enrich
• Remember, the domain model is not totally aligned
to reality.
• it is a purposeful abstraction of those aspects of our
domain relevant to our application goals.
• By enriching our domain graph with additional
properties and relationships, we effectively produce
a graph model aligned to our application’s data
needs
57
Data Modeling: Enrich
In graph terms, we are ensuring that:
•each node has the appropriate properties
•every node is in the correct semantic context.
we do this by creating named and directed (and often
attributed) relationships between the nodes to capture
the structural aspects of the domain.
58
Data Modeling: Test
• The next step is to test how suitable it is for
answering realistic queries
• Also if Graph DB are great in supporting evolving
structures there are some design decisions to
consider
• By reviewing the domain model and the resulting
graph model at this early stage, we can avoid these
pitfalls.
59
Data Modeling: Test
• In practice there are two techniques that we can
apply here
• The first, and simplest, is just to check that the graph
reads well.
• We pick a start node, and then follow relationships
to other nodes, reading each node’s role and each
relationship’s name as we go
• Doing so should create sensible sentences
60
Data Modeling: Test
• The second one is to consider queries we’ll run on
the graph.
• To validate that the graph supports the kinds of
queries we expect to run on it, we must describe
those queries.
• Given a described query if we can easily write the
query in Cypher or Gremlin we can be more certain
that the graph meets the needs of our domain.
61
Conclusions
62
Avoid Anti-Patterns
• In the general case, don’t encode entities into relationships.
• It’s also important to realize that graphs are a naturally
additive structure
• It’s quite natural to add facts in terms of domain entities and
how they interrelate adding nodes and relationships
• If we model in accordance with the questions we want to ask
of our data, an accurate representation of the domain will
emerge.
63
When to Use
• Connected Data
• Routing, Dispatch, and Location-based Services
• Recommendation Engines
64
When Not to Use
• When you need to update all or a subset of entities,
for example in analytics
• In situation when you need to apply operations that
work on the global graph
• When you don’t know the starting point of your
query
65

Mais conteúdo relacionado

Mais procurados

Chapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortalsChapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortalsnehabsairam
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless DatabasesDan Gunter
 
Appache Cassandra
Appache Cassandra  Appache Cassandra
Appache Cassandra nehabsairam
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingDATAVERSITY
 
1. introduction to no sql
1. introduction to no sql1. introduction to no sql
1. introduction to no sqlAnuja Gunale
 
Chapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsChapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsnehabsairam
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databasesAshwani Kumar
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and UsesSuvradeep Rudra
 
NoSQL databases pros and cons
NoSQL databases pros and consNoSQL databases pros and cons
NoSQL databases pros and consFabio Fumarola
 
NoSQL Data Architecture Patterns
NoSQL Data ArchitecturePatternsNoSQL Data ArchitecturePatterns
NoSQL Data Architecture PatternsMaynooth University
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Managementsameerfaizan
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesMaynooth University
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-ConceptsBhaskar Gunda
 
Cloud Deployments with Apache Hadoop and Apache HBase
Cloud Deployments with Apache Hadoop and Apache HBaseCloud Deployments with Apache Hadoop and Apache HBase
Cloud Deployments with Apache Hadoop and Apache HBaseDATAVERSITY
 

Mais procurados (20)

Chapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortalsChapter 5 design of keyvalue databses from nosql for mere mortals
Chapter 5 design of keyvalue databses from nosql for mere mortals
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless Databases
 
Appache Cassandra
Appache Cassandra  Appache Cassandra
Appache Cassandra
 
NoSQL Consepts
NoSQL ConseptsNoSQL Consepts
NoSQL Consepts
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data Modeling
 
1. introduction to no sql
1. introduction to no sql1. introduction to no sql
1. introduction to no sql
 
Chapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortalsChapter 7(documnet databse termininology) no sql for mere mortals
Chapter 7(documnet databse termininology) no sql for mere mortals
 
NoSql
NoSqlNoSql
NoSql
 
Introduction to NOSQL databases
Introduction to NOSQL databasesIntroduction to NOSQL databases
Introduction to NOSQL databases
 
Nosql
NosqlNosql
Nosql
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and Uses
 
NoSQL databases pros and cons
NoSQL databases pros and consNoSQL databases pros and cons
NoSQL databases pros and cons
 
NoSQL Data Architecture Patterns
NoSQL Data ArchitecturePatternsNoSQL Data ArchitecturePatterns
NoSQL Data Architecture Patterns
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Management
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choices
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-Concepts
 
Cloud Deployments with Apache Hadoop and Apache HBase
Cloud Deployments with Apache Hadoop and Apache HBaseCloud Deployments with Apache Hadoop and Apache HBase
Cloud Deployments with Apache Hadoop and Apache HBase
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 

Destaque

10b. Graph Databases Lab
10b. Graph Databases Lab10b. Graph Databases Lab
10b. Graph Databases LabFabio Fumarola
 
9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab9b. Document-Oriented Databases lab
9b. Document-Oriented Databases labFabio Fumarola
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2Fabio Fumarola
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2Fabio Fumarola
 
Approaching Big Data: Lesson Plan
Approaching Big Data: Lesson Plan Approaching Big Data: Lesson Plan
Approaching Big Data: Lesson Plan Bessie Chu
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databasesFabio Fumarola
 
8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab8b. Column Oriented Databases Lab
8b. Column Oriented Databases LabFabio Fumarola
 
8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker8a. How To Setup HBase with Docker
8a. How To Setup HBase with DockerFabio Fumarola
 
8. key value databases laboratory
8. key value databases laboratory 8. key value databases laboratory
8. key value databases laboratory Fabio Fumarola
 
Aloha Social Networking Portal - Design Document
Aloha Social Networking Portal - Design DocumentAloha Social Networking Portal - Design Document
Aloha Social Networking Portal - Design DocumentMilind Gokhale
 
Graph Search: The Power of Connected Data
Graph Search: The Power of Connected DataGraph Search: The Power of Connected Data
Graph Search: The Power of Connected DataCodemotion
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)Emil Eifrem
 
Dbta Webinar Realize Value of Big Data with graph 011713
Dbta Webinar Realize Value of Big Data with graph  011713Dbta Webinar Realize Value of Big Data with graph  011713
Dbta Webinar Realize Value of Big Data with graph 011713InfiniteGraph
 
Graph Databases - Where Do We Do the Modeling Part?
Graph Databases - Where Do We Do the Modeling Part?Graph Databases - Where Do We Do the Modeling Part?
Graph Databases - Where Do We Do the Modeling Part?DATAVERSITY
 
Graph Databases for SQL Server Professionals
Graph Databases for SQL Server ProfessionalsGraph Databases for SQL Server Professionals
Graph Databases for SQL Server ProfessionalsStéphane Fréchette
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQLTony Tam
 
NoSQL Graph Databases - Why, When and Where
NoSQL Graph Databases - Why, When and WhereNoSQL Graph Databases - Why, When and Where
NoSQL Graph Databases - Why, When and WhereEugene Hanikblum
 

Destaque (20)

10b. Graph Databases Lab
10b. Graph Databases Lab10b. Graph Databases Lab
10b. Graph Databases Lab
 
9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2
 
Scala and spark
Scala and sparkScala and spark
Scala and spark
 
Approaching Big Data: Lesson Plan
Approaching Big Data: Lesson Plan Approaching Big Data: Lesson Plan
Approaching Big Data: Lesson Plan
 
Hbase an introduction
Hbase an introductionHbase an introduction
Hbase an introduction
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databases
 
8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab
 
3 Git
3 Git3 Git
3 Git
 
8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker
 
8. key value databases laboratory
8. key value databases laboratory 8. key value databases laboratory
8. key value databases laboratory
 
Aloha Social Networking Portal - Design Document
Aloha Social Networking Portal - Design DocumentAloha Social Networking Portal - Design Document
Aloha Social Networking Portal - Design Document
 
Graph Search: The Power of Connected Data
Graph Search: The Power of Connected DataGraph Search: The Power of Connected Data
Graph Search: The Power of Connected Data
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
 
Dbta Webinar Realize Value of Big Data with graph 011713
Dbta Webinar Realize Value of Big Data with graph  011713Dbta Webinar Realize Value of Big Data with graph  011713
Dbta Webinar Realize Value of Big Data with graph 011713
 
Graph Databases - Where Do We Do the Modeling Part?
Graph Databases - Where Do We Do the Modeling Part?Graph Databases - Where Do We Do the Modeling Part?
Graph Databases - Where Do We Do the Modeling Part?
 
Graph Databases for SQL Server Professionals
Graph Databases for SQL Server ProfessionalsGraph Databases for SQL Server Professionals
Graph Databases for SQL Server Professionals
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQL
 
NoSQL Graph Databases - Why, When and Where
NoSQL Graph Databases - Why, When and WhereNoSQL Graph Databases - Why, When and Where
NoSQL Graph Databases - Why, When and Where
 

Semelhante a 10. Graph Databases

Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jAbdullah Hamidi
 
Database Models, Client-Server Architecture, Distributed Database and Classif...
Database Models, Client-Server Architecture, Distributed Database and Classif...Database Models, Client-Server Architecture, Distributed Database and Classif...
Database Models, Client-Server Architecture, Distributed Database and Classif...Rubal Sagwal
 
Relational and non relational database 7
Relational and non relational database 7Relational and non relational database 7
Relational and non relational database 7abdulrahmanhelan
 
Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxMaryJoseph79
 
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​EdwinJacob5
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptrekhasai2468
 
Data Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & EngineeringData Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & Engineeringacemindia
 
Seeing Graphs - How to successfully visualize connected data
Seeing Graphs - How to successfully visualize connected dataSeeing Graphs - How to successfully visualize connected data
Seeing Graphs - How to successfully visualize connected dataCambridge Intelligence
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageBethmi Gunasekara
 
Selecting the right database type for your knowledge management needs.
Selecting the right database type for your knowledge management needs.Selecting the right database type for your knowledge management needs.
Selecting the right database type for your knowledge management needs.Synaptica, LLC
 
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptxChapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptxmicayaseloisa
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Jotham Gadot
 
DBMS data modeling.pptx
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptxMrwafaAbbas
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfTamiratDejene1
 
How Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and BeyondHow Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and BeyondNeo4j
 
Linked data and the future of libraries
Linked data and the future of librariesLinked data and the future of libraries
Linked data and the future of librariesRegan Harper
 
Types of data bases
Types of data basesTypes of data bases
Types of data basesJanu Jahnavi
 

Semelhante a 10. Graph Databases (20)

Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
 
Database Models, Client-Server Architecture, Distributed Database and Classif...
Database Models, Client-Server Architecture, Distributed Database and Classif...Database Models, Client-Server Architecture, Distributed Database and Classif...
Database Models, Client-Server Architecture, Distributed Database and Classif...
 
Relational and non relational database 7
Relational and non relational database 7Relational and non relational database 7
Relational and non relational database 7
 
Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
 
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​
RELATIONAL MODEL OF DATABASES AND OTHER CONCEPTS OF DATABASES​
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
Design approach
Design approachDesign approach
Design approach
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.ppt
 
Data Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & EngineeringData Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & Engineering
 
Seeing Graphs - How to successfully visualize connected data
Seeing Graphs - How to successfully visualize connected dataSeeing Graphs - How to successfully visualize connected data
Seeing Graphs - How to successfully visualize connected data
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data Storage
 
Selecting the right database type for your knowledge management needs.
Selecting the right database type for your knowledge management needs.Selecting the right database type for your knowledge management needs.
Selecting the right database type for your knowledge management needs.
 
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptxChapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02
 
DBMS data modeling.pptx
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptx
 
Data Models
Data ModelsData Models
Data Models
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdf
 
How Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and BeyondHow Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and Beyond
 
Linked data and the future of libraries
Linked data and the future of librariesLinked data and the future of libraries
Linked data and the future of libraries
 
Types of data bases
Types of data basesTypes of data bases
Types of data bases
 

Mais de Fabio Fumarola

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and DockerFabio Fumarola
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and dockerFabio Fumarola
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and dockerFabio Fumarola
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce Fabio Fumarola
 

Mais de Fabio Fumarola (6)

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and docker
 
08 datasets
08 datasets08 datasets
08 datasets
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
 

Último

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 

Último (20)

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 

10. Graph Databases

  • 1. Graph Oriented Databases Ciao ciao Vai a fare ciao ciao Dr. Fabio Fumarola
  • 2. Outline • Introduction • The Lack of relationship for RDBMS and NoSQL • Graph Databases: Features • Relations • Query Language • Data Modeling with Graphs • Conclusions 2
  • 3. Introduction • We live in a connected world • Everything is connected: Social Network, Biology, Bioinformatics • The NoSQL databases analyzed store data using aggregate • Here we compare graph databases with relational databases and aggregate NOSQL in storing graph data 3
  • 4. Three Facts 1. Relational Databases Lack Relationships 1. NoSQL Databases also Lack Relationships 2. Graph Databases Embrace Relationships 4
  • 5. Relational Databases Lack Relationships • For decades we tried to accommodate connected, semi-structured datasets inside relational databases. • But: – relational databases are designed to codify tabular structures – They struggle when modeling ad hoc exceptional relationships that are in real world. 5
  • 6. Relational Databases Lack Relationships • Relationships in relational database only mean joining tables • But we want to model the semantic of relationships that connect real world • As outlier data multiplies: 1. The structure of the dataset becomes more complex and less uniform 2. The relational data becomes more complex and less uniform (large join tables, sparsely populated rows, a lot o null values) 6
  • 7. Example of customer-centric orders • Complex joins • Foreign key constraints • Sparse table with null values • Reciprocal queries are costly “What products did a customer buy?” 7
  • 8. NoSQL Databases Also Lack Relationships • key-value, document, or column-oriented store sets of disconnected documents/values/columns • One well-known strategy for adding relationships is to embed an aggregate’s identifier inside the field belonging to another aggregate • But this require joins at the application level • Some NoSQL have some concept of navigability but it is expensive for complex joins 8
  • 9. Example of aggregate oriented orders • Some properties are references to foreign aggregates • This relationship are not first-class citizens • Are not intended as real realtionships 9
  • 10. Example of a Small Social Network • it’s easy to find a user’s immediate friends • friendship isn’t always reflexive • We can have brute-force scan across the whole dataset looking for friends entries 10
  • 11. Graph Databases Embrace Relationships • The previous examples have dealt with implicitly connected data • We infer semantic dependencies between entities • We model the data based on this connections • Our application have to navigate on this flat and disconnected data, and deal with slow queries. • In contrast, in the graph world, connected data is stored as connected data 11
  • 12. Example Social Network 12 • The node user:Bob is a Vertex with a property Bob • We also see relations which are Edges: • Boss_of • Friend_of • Married_to
  • 15. Consistency • Since Graph DBs operate on connected nodes, they could not scale well distributing nodes across servers. • There are solutions supporting distribution: – Neo4j uses one master and several slaves – OrientDB uses MVCC for distributed eventual data structures – TitanDB partition data by using HBase or Cassandra 15
  • 16. Transactions • Most of the Graph DB are ACID-compliant • Before doing an operation we have to start a transaction. • Without wrapping operations in a transaction we will get an Exception. 16
  • 17. Availability • Neo4j from version 1.8 achieves availability by providing for replicated slaves. • Infinity Graph, FlockDB and TitanDB provides for distribute storage of the nodes. • Neo4J uses Zookeeper to keep track of the last transaction Ids persisted on each slave node and the current master node 17
  • 19. Relations • Relations in a graph naturally forms paths. • Querying or traversing the graph involves following a path. • A query on the graph is also known as traversing the graph • As advantage we can change the traversing requirements without changing nodes and edges 19
  • 20. Relations • In graph databases traversal operation are highly efficient. • In the book Neo4j in Action, Partner and Vukotic perform an experiment comparing relational store and Neo4j 20
  • 21. Relations • In a depth two (friend-of-friend), both relational db and graph db perform well enough • But when we do the depth three it clear that relational db can no longer deal 21
  • 22. Relations • Both aggregate store and relational databases perform poorly because of the index lookups. • Graphs, on the other hand, use index-free adjacency list to ensure that traversing connected data is extremely fast. 22
  • 23. Relations another case study • Let us consider the purchase history of a user as connected data. • If we notice that users who buy strawberry ice cream also buy espresso beans, we can start to recommend those beans to users who normally only buy the ice cream. 23
  • 24. Relations and Recommendations • The previous was a one dimensional recommendation • We can join our graph with graph from other domains. • For example, we can ask to fine – “all the flavors of ice cream liked by people who live near a user, and enjoy espresso, but dislike Brussels sprouts.” 24
  • 25. Relations and Patterns • We can use relations to query graph-patterns • Such pattern-matching queries are: – extremely difficult to write in SQL – And are laborious to write against aggregate stores • In both cases they tend to perform very poorly • In the other hand, graph databases are optimized for such kind of queries 25
  • 27. Query Language • Graph DBs support query languages such as Gremlin, Cypher and SPARQL • Gremlin is a DSL for traversing graphs; • It can traverse all the graph databases implementing the Blueprints 27
  • 28. 1. Indexing: Nodes and Edges • Indexes are necessary to find the starting node to being traversal. • How Indexes works: – Can index properties of nodes and edges. – Adds are done in transactions • Nodes retrieved can be used to raise queries 28
  • 29. 2. Querying In- Out- Relationships • Having a node we can query both for Incoming and Outgoing relationships. • We can apply directional filters on the queries when querying for relations 29
  • 30. 3. Querying Breadth- Depth- • Graph databases are really powerful to query for incoming and outgoing relationships. • Moreover, we can make the traverser go top-down or sideways on the graph by using: – BREADTH_FIRST or – DEPTH_FIRST 30
  • 31. 4. Querying Paths • An other good feature of graph databases is – finding paths between two nodes. – Determining if there are multiple paths – finding the shortest path • Many Graph DBs use algorithms such as the Dijkstra’s algorithm for finding shortest paths. 31
  • 32. 5. Querying Paths • Finally, with Graph DBs it is possible to use Match operator • The MATCH is used for matching patterns in relationships • The WHERE filters the properties on a node or relationship • The RETURN specifies what to get in the result set. 32
  • 33. Data Modeling with Graphs Intro 33
  • 34. Data Modeling with Graphs how do we model the world in graph terms? 34
  • 35. how do we model the world in graph terms? • Formalization of the base model • Enrich the model • Testing the model 35
  • 36. Formalization of the base model • Modeling is an abstracting activity motivated by a particular need or goal • We model in order to define structures that can manipulated. • There are no natural representations of the world the way it “really is,” • There are just many purposeful selections, abstractions, and simplifications that useful for satisfying a particular goal 36
  • 37. Formalization of the base model • Graph data modeling is different from many other techniques. • There is a close affinity between logical and physical models. • In relational databases we start from a logical model to arrive to the physical model. • With graph databases, this gap shrinks considerably. 37
  • 38. The Graph Model • A property graph is made up of nodes, relationships, and properties. 38
  • 39. Publishing Messages • We organize messages in order 39
  • 40. Nodes Nodes contain properties •Think of nodes as documents that store properties in the form of arbitrary key-value pairs. •The keys are strings and the values are arbitrary data types. 40
  • 41. Relationships Relationships connect and structure nodes. •A relationship always has a direction, a label, and a start node and an end node—there are no dangling relationships. •Together, a relationship’s direction and label add semantic clarity to the structuring of nodes. 41
  • 42. Relationships: Attributes Like nodes, relationships can also have properties. •The ability to add properties to relationships is particularly useful for: – Providing additional metadata for graph algorithms – Adding additional semantics to relationships (including quality and weight), – and for constraining queries at runtime. 42
  • 43. Modeling Steps: Outline • The initial stage of modeling is similar to the first stage of many other data modeling techniques, that is: – to understand and agree on the entities in the domain – how they interrelate – and the rules that govern their state transitions 43
  • 44. Describe the Model in Terms of the Application’s Needs • Agile user stories provide a concise means for expressing an outside-in, user-centered view of the application needs. • Here’s an example of a user story for a book review web application: – AS A reader who likes a book, – I WANT to know which books other readers who like the same book have liked, – SO THAT I can find other books to read. 44
  • 45. Describe the Model in Terms of the Application’s Needs • This story expresses a user need, which motivates the shape and content of our data model. • From a data modeling point of view: – the AS A clause establishes a context comprising two entities—a reader and a book—plus the LIKES relationship that connects them. – The I WANT clause exposes more LIKES relationships, and more entities: other readers and other books. 45
  • 46. Describe the Model in Terms of the Application’s Needs • The entities and relationships in analyzing the user story quickly translate into a simple data model 46
  • 47. Modeling Rationale • Use nodes to represent entities • Use relationships both: – to express the connections between entities and – to establish semantic context for each entity • Use relationship direction to further clarify relationship semantics 47
  • 48. Describe the Model: Guidelines • Use node properties – to represent entity attributes, plus any necessary entity metadata, such as timestamps, version numbers, etc • Use relationship properties – to express the strength, weight, or quality of a relationship, plus any necessary relationship metadata, such as timestamps, version numbers, etc. 48
  • 49. Modeling Temporal Relations as Nodes • When two or more domain entities interact for a period of time, a fact emerges • We represent these facts as separate nodes • In the following examples we show how we might model facts and actions using intermediate nodes. 49
  • 50. Example: Employment Ian was employed as an engineer at Neo Technology 50
  • 51. Example: Performance William Hartnell played the Doctor in the story The Sensorites 51
  • 52. Example: Emailing Ian emailed Jim, and copied in Alistair 52
  • 53. Example: Timeline Tree 53 A timeline tree showing the broadcast dates for four episodes of a TV program
  • 54. Example: Linked-List A doubly linked list representing a time-ordered series of events 54
  • 55. Iterative and Incremental • We develop the data model feature by feature, user story by user story • This will ensure we identify the relationships our application will use to query the graph • With the iterative and incremental delivery of application features we will be a corrected model that provides the right abstraction 55
  • 56. Data Modeling: Enrich • The next steps diverges from the relational data methodology • Instead of transforming a domain model’s graph-like representation into tables, we enrich it. • That is, for each entity in our domain, “we ensure that we’ve captured both the properties and the connections to neighboring entities necessary to support our application goals”. 56
  • 57. Data Modeling: Enrich • Remember, the domain model is not totally aligned to reality. • it is a purposeful abstraction of those aspects of our domain relevant to our application goals. • By enriching our domain graph with additional properties and relationships, we effectively produce a graph model aligned to our application’s data needs 57
  • 58. Data Modeling: Enrich In graph terms, we are ensuring that: •each node has the appropriate properties •every node is in the correct semantic context. we do this by creating named and directed (and often attributed) relationships between the nodes to capture the structural aspects of the domain. 58
  • 59. Data Modeling: Test • The next step is to test how suitable it is for answering realistic queries • Also if Graph DB are great in supporting evolving structures there are some design decisions to consider • By reviewing the domain model and the resulting graph model at this early stage, we can avoid these pitfalls. 59
  • 60. Data Modeling: Test • In practice there are two techniques that we can apply here • The first, and simplest, is just to check that the graph reads well. • We pick a start node, and then follow relationships to other nodes, reading each node’s role and each relationship’s name as we go • Doing so should create sensible sentences 60
  • 61. Data Modeling: Test • The second one is to consider queries we’ll run on the graph. • To validate that the graph supports the kinds of queries we expect to run on it, we must describe those queries. • Given a described query if we can easily write the query in Cypher or Gremlin we can be more certain that the graph meets the needs of our domain. 61
  • 63. Avoid Anti-Patterns • In the general case, don’t encode entities into relationships. • It’s also important to realize that graphs are a naturally additive structure • It’s quite natural to add facts in terms of domain entities and how they interrelate adding nodes and relationships • If we model in accordance with the questions we want to ask of our data, an accurate representation of the domain will emerge. 63
  • 64. When to Use • Connected Data • Routing, Dispatch, and Location-based Services • Recommendation Engines 64
  • 65. When Not to Use • When you need to update all or a subset of entities, for example in analytics • In situation when you need to apply operations that work on the global graph • When you don’t know the starting point of your query 65

Notas do Editor

  1. For example, users often want to see their order history, so we’ve added a linked list structure to the graph that allows us to find a user’s most recent order by following an outgoing MOST_RECENT relationship. We can then iterate through the list, going further back in time, by following each PREVIOUS relationship. If we want to move forward in time, we can follow each PREVIOUS relationship in the opposite direction, or add a reciprocal NEXT relationship.