Top Banner

Click here to load reader

27

Graph Databases 101

Jan 27, 2015

Download

Technology

Paulo Traça

Graph Databases 101 with Neo4J and Friends
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Graph Databases 101

with Neo4j and friends !

Paulo Traça [email protected]

Graph DB 101

Page 2: Graph Databases 101

The Problem

Page 3: Graph Databases 101

Aggregation Ordered data Truly tabular data Few or clearly defined relationships

RDBMS are good at

Page 4: Graph Databases 101

Relational databases aren’t very good with relationships.

Page 5: Graph Databases 101

Graph DB’s

Page 6: Graph Databases 101

A graph database uses graph structure with nodes, edges, and properties to represent and store data. !

By definition, a graph database is any storage system that provides index-free adjacency. This means that every element contains a direct pointer to its adjacent element and no index lookups are necessary.

Page 7: Graph Databases 101

NODESNodes represent Entities such as people, businesses, accounts, or any other item you might want to keep track of.

Page 8: Graph Databases 101

PropertiesProperties are pertinent information that relate to nodes.

Page 9: Graph Databases 101

EDGESEdges are the lines that connect nodes to nodes or nodes to properties and they represent the relationship between the two. Most of the important information is really stored in the edges. Meaningful patterns emerge when one examines the connections and interconnections of nodes, properties, and edges.

Page 10: Graph Databases 101

Graph databases focus on the interconnection

between Entities

Page 11: Graph Databases 101

Graph databases are often faster for associative data sets !

map more directly to the structure of object-oriented applications !

Scale more naturally to large data sets as they do not typically require expensive join operations. !

As they depend less on a rigid schema, they are more suitable to manage ad-hoc and changing data with evolving schemas.

Compared with relational databases

Page 12: Graph Databases 101

What to find vs

How to find// Find all the directors who have directed a movie scored by John Williams // that starred Kevin Bacon !START actor=(actors, 'Kevin Bacon'), composer=(compsers, 'John Williams') MATCH (actor)-[:IN]->(movie)<-[:DIRECTED]-(director),       (movie)<-[:SCORED]-(composer) RETURN director

Page 13: Graph Databases 101

Modelling a Domain with Graphs

Graphs are "whiteboard-friendly" Nouns become nodes Verbs become relationships Properties are adjectives and adverbs

Page 14: Graph Databases 101

NEO4J

Page 15: Graph Databases 101

Key FeaturesJava Based Property Graph Model Uses Lucene for indexing of graph/relationship properties ACID Transactions Massive scalability Extensible High performance on deep transversal

Page 16: Graph Databases 101

Key FeaturesProperty Graph Model !

. Nodes

. Nodes have key / value properties

. Relationships between nodes

. Relationships have labels

. Relationships have key / value properties

. Relationships are directed but transversal at equals speed in both directions

. Semantics of the directions is up to the applications

Page 17: Graph Databases 101

Key FeaturesACID Transactions Custom JTA/JTS compliant transaction manager distributed transactions two-phase commit (2PC) Transaction recovery deadlock detection

!

Massive Scalability Supporting billions of nodes/relationships props on a single machine

Page 18: Graph Databases 101

Key Features.Can run embedded or Standalone via REST . Plugins : Spatial data, Lucene, RDF, SOLR . Runs on major platforms : Mac | Windows | Unix . Extensive documentation . Active community . Open Source

Page 19: Graph Databases 101

Enterprise strength database

Page 20: Graph Databases 101

Finding Stuff

Page 21: Graph Databases 101

TRANSVERSAL

Page 22: Graph Databases 101

CYPHERCypher is a declarative graph query language that allows for expressive and efficient querying and updating of the graph store without having to write traversals through the graph structure in code

Page 23: Graph Databases 101

CYPHERSTART: Starting points in the graph, obtained via index lookups or by element IDs.

MATCH: The graph pattern to match, bound to the starting points in START.

WHERE: Filtering criteria.

RETURN: What to return.

CREATE: Creates nodes and relationships.

DELETE: Removes nodes, relationships and properties.

SET: Set values to properties.

FOREACH: Performs updating actions once per element in a list.

WITH: Divides a query into multiple, distinct parts.

Page 24: Graph Databases 101

Graph AlgorithmsShortest paths,

all paths,

all simple paths,

Dijkstra and

A*.

Page 25: Graph Databases 101

REST API

Page 26: Graph Databases 101

DEMO TIME

Page 27: Graph Databases 101

That’s All Folks Thank you!

!

!

@ptraca