Application Modeling with Graph Databases - Relationships are cool

14 %
86 %
Information about Application Modeling with Graph Databases - Relationships are cool
Software

Published on April 5, 2014

Author: LarsMartinLE

Source: slideshare.net

Description

My slides on Application Modeling with Graph Databases at JUG Saxony Day 2014.

Application Modeling with Graph Databases – Relationships are cool! Lars Martin, JUG Saxony Day, 04.04.2014

Application Modeling with Graph Databases – Relationships are cool! §  Developer, Architect, Consultant §  Java Enterprise, Eclipse, Continuous … §  Entrepreneur since 1998 Who’s the guy?

Agenda ² Status Quo ² SQL Join Hell ² Graph Basics ² Application Modeling Application Modeling with Graph Databases – Relationships are cool!

Application Modeling with Graph Databases – Relationships are cool! Status Quo http://db-engines.com/en/ranking_definition

Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(1) Customer Id Name Address 1Robert 3 2Lars 7 3Michael 23 Address Id Location 3Berlin 4Munich 7Dresden 23Leipzig CustomerAddress CId AId 1 3 2 7 2 8 3 23 Address Id Location 3Berlin 7Dresden 8New York 23Leipzig Address Id Customer Location 3 1Berlin 7 2Dresden 8 2New York 23 3Leipzig Customer Id Name 1Robert 2Lars 3Michael 1:1 Relationship m:n Relationship 1:n Relationship Customer Id Name 1Robert 2Lars 3Michael

Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(2)

Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(3) ­ all JOINs are executed every time you query (traverse) the relationship ­ executing a JOIN means to search for a key in another table ­ with Indices executing a JOIN means to lookup a key ­ B-Tree Index: O(log(n)) ­ more entries è more lookups è slower JOINs

Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness G = (V, E)Graph Vertex Edgeh"p://de.wikipedia.org/wiki/Graph_(Graphentheorie)  

Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness

Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness Vertices •  unique identifier •  outgoing edges •  incoming edges •  key/value pairs Edges •  unique identifier •  start vertex •  end vertex •  type •  key/value pairs https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph index-free adjacency (≈ O(1))

Application Modeling with Graph Databases – Relationships are cool! Real World Graphs (1) maps closely to the data model noun = vertex verb = edge

Application Modeling with Graph Databases – Relationships are cool! Real World Graphs (2) “whiteboard” friendly

Application Modeling with Graph Databases – Relationships are cool! Ø  Social: Facebook, Twitter, LinkedIn Ø  Recommendations: Amazon, MovieDB Ø  Logistics: Package Routing Ø  Financial: Fraud Detection Ø  Software: Dependency Management Ø  Authorization & Access Control: Ø  … Real World Graphs (3)

Application Modeling with Graph Databases – Relationships are cool! Ø  Social: Facebook, Twitter, LinkedIn Ø  Recommendations: Amazon, MovieDB Ø  Logistics: Package Routing Ø  Financial: Fraud Detection Ø  Software: Dependency Management Ø  Authorization & Access Control: Ø  … Real World Graphs (3) our area of activities

Application Modeling with Graph Databases – Relationships are cool! Application Modeling Spring Data – projects.spring.io/spring-data ü  Spring Data Neo4j supports property graph features XO - eXtended Objects – github.com/buschmais/xo ü  Lightweight Datastore-agnostic ORM ü  Implementation of “Composite Pattern” ü  Interface based (no POJOS), multiple inheritance ü  XO-Neo4j supports property graph features

Application Modeling with Graph Databases – Relationships are cool! Application Modeling

Application Modeling with Graph Databases – Relationships are cool! Application Modeling @Label public interface User { @Indexed(unique = true) String getName(); void setName(String name); @Relation("POSTED") @Outgoing Set<Tweet> getTweets(); @Relation("FOLLOWS") @Outgoing Set<User> getFollowing(); } @Label public interface Tweet { @Indexed(unique = true) long getTweetId(); void setTweetId(long id); String getText(); void setText(String text); @Relation("POSTED") @Incoming User getSender(); void setSender(User sender); @Relation("MENTIONED") @Outgoing Set<User> getMentions(); … }

MATCH (me)-[:POSTED]->(tweet)-[:MENTIONED]->(user) WHERE me.name = 'Neo4j’ AND NOT (me)-[:FOLLOWS]->(user) WITH user ORDER BY user.name RETURN DISTINCT user   Application Modeling with Graph Databases – Relationships are cool! Application Modeling @ResultOf @Cypher("MATCH (me)-[:POSTED]->(tweet)- [:MENTIONED]->(user) WHERE id(me) = id({this}) AND NOT (me)-[:FOLLOWS]->(user) WITH user ORDER BY user.name RETURN DISTINCT user") Result<User> suggestFriends();  

Demo Application Modeling with Graph Databases – Relationships are cool! Application Modeling

Relational Database •  tabular data structures Graph Database •  connected data, esp. multiple degrees •  schema-less Application Modeling with Graph Databases – Relationships are cool! Application Modeling “A relational database may tell you the average age of everyone in this place … … but a graph database will tell you who is most likely to buy you a beer.”

SMB GmbH – Plauenscher Ring 21 – D-01187 Dresden Dipl.-Inf. Lars Martin +49-(0)173-64 24 461 lars.martin@smb-tec.com

Add a comment

Related presentations

Speaker: Matt Stine Developing for the Cloud Track Marc Andressen has famou...

This presentation explains how to develop a Web API in Java using (JAX-RS or Restl...

1 App,

1 App,

November 10, 2014

How to bring innovation to your organization by streamlining the deployment proces...

Cisco Call-control solutions can handle voice, video and data

Nathan Sharp of Siemens Energy recently spoke at the SAP Project Management in Atl...

Related pages

Relational Databases vs. Graph Databases: A Comparison

Relational databases have been the power-horse of software applications ... modeling with relational databases, ... Relationships Matter - Neo4j Graph ...
Read more

Relationships are cool! - Neo4j Graph Database

Neo4j Graph Database; What is Neo4j? ... Data Modeling; Language Drivers; Tools & Integration; ... Relationships are cool! News;
Read more

Graph Databases, published by O'Reilly Media

Graph Databases, the definitive book ... Graph Databases Embrace Relationships 3. ... Building a Graph Database Application Data Modeling
Read more

Database Modeling Tutorial Covering Basics of Database ...

Database modeling covering ... find and understand different relationships ... oriented applications. Graph databases are generally easier ...
Read more

sql - Comparision of Relational databases and Graph ...

Comparision of Relational databases and Graph databases. ... Relationships are therefore first ... Graph databases make modelling and querying much more ...
Read more

Graph database - Wikipedia, the free encyclopedia

... a graph database is a database that uses ... for managing Twitter-like graph data (single-hop relationships). ... for modeling RDF graphs, ...
Read more

What is graph database? - Definition from WhatIs.com

... , map and query relationships. A graph database is essentially a ... data modeling - A data model can ... Internet applications - This WhatIs.com ...
Read more

Has anyone used Graph-based Databases (http://neo4j.org ...

Has anyone used graph-based databases? ... database if you can. If your application doesn't ... their relationships, which is spot on for a graph ...
Read more