SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Seminar
BigData, NoSQL graph database for
Java developers*

Presenter:     Evgeny Hanikblum
Data is getting bigger:
“Every 2 days we
create as much
information as we did
up to 2003”

– Eric Schmidt, Google
Big Data Technologies
NoSQL Overview
NoSQL->Not Only SQL
Key Value Stores
• Most Based on Dynamo: Amazon Highly
  Available Key-Value Store
• Data Model:
  – Global key-value mapping
  – Big scalable HashMap
  – Highly fault tolerant (typically)
• Projects:
Key Value Stores
• Pros:
  – Simple data model
  – Scalable
• Cons
  – Create your own “foreign keys”
  – Poor for complex data
Column Databases
• Most Based on BigTable: Google’s Distributed
  Storage System for Structured Data
• Data Model:
  – A big table, with column families
  – Map Reduce for querying/processing
• Projects:
Column Databases
• Pros:
  – Supports Simi-Structured Data
  – Naturally Indexed (columns)
  – Scalable
• Cons
  – Poor for interconnected data
Document Databases
• Data Model:
  – A collection of documents
  – A document is a key value collection
  – Index-centric, lots of map-reduce
• Projects :
Document Databases
• Pros:
  – Simple, powerful data model
  – Scalable
• Cons
  – Poor for interconnected data
  – Query model limited to keys and indexes
  – Map reduce for larger queries
Graph Databases
• Data Model:
  – Nodes and Relationships
• Projects:
Graph Databases
• Pros:
  – Powerful data model, as general as RDBMS
  – Connected data locally indexed
  – Easy to query
• Cons
  – Sharding ( lots of people working on this)
     • Scales UP reasonably well
  – Requires rewiring your brain
Why you need GraphDB ?
GraphDB Overview
Because of Data expanded into
relationships
GraphDB Overview
Because of Data became
interconnected
When should I use it ?
Use graph db, if you should deal with
something like this :
or this …
or this …
GraphDB Overview
Data is more connected:
•   Text (content)
•   HyperText (added pointers)
•   RSS (joined those pointers)
•   Blogs (added pingbacks)
•   Tagging (grouped related data)
•   RDF (described connected data)
•   GGG (content + pointers + relationships +
    descriptions)
GraphDB Overview
Data is less structured:
• If you tried to collect all the data of every
  movie ever made, how would you model
  it?
• Actors, Characters, Locations, Dates, Costs,
   Ratings, Showings, Ticket Sales, etc.
What is Graph
What is Graph


• An abstract representation of a set of
  objects where some pairs are connected by
  links.
          Object (Vertex, Node)

          Link (Edge, Arc, Relationship)
Different Kinds of Graphs
• Undirected Graph
• Directed Graph

• Pseudo Graph
• Multi Graph


• Hyper Graph
More Kinds of Graphs
• Weighted Graph

• Labeled Graph

• Property Graph
What is Graph DB
What is a Graph DB?


• A database with an explicit graph structure
• Each node knows its adjacent nodes
• As the number of nodes increases, the cost
  of a local step (or hop) remains the same
• Plus an Index for lookups
Compared to Relational Databases
 Optimized for aggregation   Optimized for connections
What is Neo4j?
What is Neo4j?

• A java based graph database
• Property Graph
• Full ACID (atomicity, consistency, isolation, durability)
• High Availability (with Enterprise Edition)
• 32 Billion Nodes, 32 Billion Relationships,
  64 Billion Properties
• Embedded Server
• REST API
What is Neo4j?

•   Both nodes and relationships can have metadata.
•   Integrated pattern-matching-based query language (“Cypher”).
•   Also the “Gremlin” graph traversal language can be used.
•   Indexing of nodes and relationships. (Lucene)
•   Nice self-contained web admin.
•   Advanced path-finding with multiple algorithms.
•   Optimized for reads.
•   Has transactions (in the Java API)
•   Scriptable in Groovy
•   Online backup, advanced monitoring and High Availability is
    AGPL/commercial licensed
Neo4j is good for :
• Highly connected data (social networks)
• Recommendations (e-commerce)
• Path Finding (how do I know you?)

• A* (Least Cost path)
• Data First Schema (bottom-up, but you still
  need to design)
how do I know you?
how can I get there ?
If you’ve ever
•   Joined more than 7 tables together
•   Modeled a graph in a table
•   Written a recursive CTE
•   Tried to write some crazy stored procedure
    with multiple recursive self and inner joins



    You should use Neo4j
rewiring you brain
       Language        LanguageCountry          Country

language_code        language_code       country_code
language_name        country_code        country_name
word_count           primary             flag_uri




       Language                                 Country

name                                     name
                        IS_SPOKEN_IN
code                                     code
word_count              as_primary       flag_uri
rewiring you brain
                 name: “Canada”
                 languages_spoken: “[ „English‟, „French‟ ]”




                            language:“English”    spoken_in    name: “USA”




name: “Canada”




                 language:“Frech”     spoken_in      name: “France”
rewiring you brain
                           Country

                   name
                   flag_uri
                   language_name
                   number_of_words
                   yes_in_langauge
                   no_in_language
                   currency_code


       Country                              Language
name                                 name
flag_uri                             number_of_words
                          SPEAKS
                                     yes
                                     no

                          Currency
                     code
                     name
show me the code!
GraphDatabaseService graphDb =
       new EmbeddedGraphDatabase("var/neo4j");

Node david = graphDb.createNode();
Node andreas = graphDb.createNode();

david.setProperty("name", "David Montag");
andreas.setProperty("name", "Andreas Kollegger");

Relationship presentedWith =
       david.createRelationshipTo(andreas,
                      PresentationTypes.PRESENTED_WITH);

presentedWith.setProperty("date", System.currentTimeMillis());
Neo4j data browser
Neo4j data browser
Neoclipse
console.neo4j.org




       Try it right now:
       start n=node(*) match n-[r:LOVES]->m return n, type(r), m
       Notice the two nodes in red, they are your result set.
Spring-Data-Neo4J
Spring-Data-Neo4J
• Focus on Spring Data Neo4j
• VMWare is collaborating with Neo Technology, the
  company behind the Neo4j graph database.
• Improved programming model: Annotation-based
  programming model for applications with rich
  domain models
• Cross-store persistence: Extend existing JPA
  application with NoSQL persistence
• Tagging (grouped related data)
• RDF (described connected data)
Spring-Data-Neo4J
@NodeEntity
@NodeEntity
public class Actor {
       private String name;
       private int age;
       private HairColor hairColor;
       private transient String nickname;

}
Spring-Data-Neo4J
@NodeEntity
 public class Movie {

    @GraphId Long id;

    @Indexed(type = FULLTEXT, indexName = "search")
    String title;

    Person director;

    @RelatedTo(type="ACTS_IN", direction = INCOMING)
    Set<Person> actors;

    @RelatedToVia(type = "RATED")
    Iterable<Rating> ratings;

    @Query("start movie=node({self}) match movie-->genre<--similar return similar")
    Iterable<Movie> similarMovies;
}
Spring-Data-Neo4J
@RelationshipEntity
@RelationshipEntity
public class Role {
       @StartNodeprivate Actor actor;
       @EndNodeprivate Movie movie;
       privateString roleName;

}
Spring-Data-Neo4J
@RelationshipEntity
public class Role {
       @StartNode private   Actor actor;
       @EndNode   private   Movie movie;

       private   String roleName;

}

@NodeEntity
public class Actor {
       @RelatedToVia(type = “ACTS_IN”)
       private Iterable<Role> roles;
}
How they did that ?
NoSql->Graph DB->Neo4J
Lecturer : Evgeny Hanikblum @ AlphaCSP:OracleWeek2012:Israel
Email : evgenyh@alphacsp.com

Weitere ähnliche Inhalte

Was ist angesagt?

Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) David Fombella Pombal
 
PgREST: Node.js in the Database
PgREST: Node.js in the DatabasePgREST: Node.js in the Database
PgREST: Node.js in the DatabaseAudrey Tang
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendationsproksik
 
Getting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4jGetting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4jSuroor Wijdan
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from JavaNeo4j
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Jordi Valverde
 
NoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresNoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresEDB
 
Introduction to FPDF
Introduction to FPDFIntroduction to FPDF
Introduction to FPDFJeremy Curcio
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph DatabasesMax De Marzi
 
MongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsMongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsSteven Francia
 
What is Python JSON | Edureka
What is Python JSON | EdurekaWhat is Python JSON | Edureka
What is Python JSON | EdurekaEdureka!
 
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...Lucidworks
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlpankit_ppt
 

Was ist angesagt? (20)

Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
 
PgREST: Node.js in the Database
PgREST: Node.js in the DatabasePgREST: Node.js in the Database
PgREST: Node.js in the Database
 
Intro to Neo4j 2.0
Intro to Neo4j 2.0Intro to Neo4j 2.0
Intro to Neo4j 2.0
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
 
Getting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4jGetting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4j
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from Java
 
Graph databases
Graph databasesGraph databases
Graph databases
 
Graph databases
Graph databasesGraph databases
Graph databases
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011
 
NoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresNoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured Postgres
 
No sql way_in_pg
No sql way_in_pgNo sql way_in_pg
No sql way_in_pg
 
Introduction to FPDF
Introduction to FPDFIntroduction to FPDF
Introduction to FPDF
 
MongoDB for Genealogy
MongoDB for GenealogyMongoDB for Genealogy
MongoDB for Genealogy
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
MongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsMongoDB, E-commerce and Transactions
MongoDB, E-commerce and Transactions
 
NetBase API Presentation
NetBase API PresentationNetBase API Presentation
NetBase API Presentation
 
What is Python JSON | Edureka
What is Python JSON | EdurekaWhat is Python JSON | Edureka
What is Python JSON | Edureka
 
Neo4j in Depth
Neo4j in DepthNeo4j in Depth
Neo4j in Depth
 
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...
Leveraging Lucene/Solr as a Knowledge Graph and Intent Engine: Presented by T...
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlp
 

Ähnlich wie NoSQL, Neo4J for Java Developers , OracleWeek-2012

Graph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemGraph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemMarco Parenzan
 
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_Spark
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_SparkSunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_Spark
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_SparkMopuru Babu
 
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_Spark
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_SparkSunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_Spark
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_SparkMopuru Babu
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital.AI
 
Enterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsightEnterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsightPaco Nathan
 
Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...source{d}
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jCorie Pollock
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational DatabasesChris Baglieri
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databasesthai
 
Hadoop with Python
Hadoop with PythonHadoop with Python
Hadoop with PythonDonald Miner
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015Himanshu Desai
 
Gerry McNicol Graph Databases
Gerry McNicol Graph DatabasesGerry McNicol Graph Databases
Gerry McNicol Graph DatabasesGerry McNicol
 
Apache Spark 101 - Demi Ben-Ari - Panorays
Apache Spark 101 - Demi Ben-Ari - PanoraysApache Spark 101 - Demi Ben-Ari - Panorays
Apache Spark 101 - Demi Ben-Ari - PanoraysDemi Ben-Ari
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbMongoDB APAC
 

Ähnlich wie NoSQL, Neo4J for Java Developers , OracleWeek-2012 (20)

Graph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemGraph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft Ecosystem
 
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_Spark
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_SparkSunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_Spark
Sunshine consulting mopuru babu cv_java_j2_ee_spring_bigdata_scala_Spark
 
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_Spark
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_SparkSunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_Spark
Sunshine consulting Mopuru Babu CV_Java_J2ee_Spring_Bigdata_Scala_Spark
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
 
Neo4j graph database
Neo4j graph databaseNeo4j graph database
Neo4j graph database
 
Lecture7
Lecture7Lecture7
Lecture7
 
Enterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsightEnterprise Data Workflows with Cascading and Windows Azure HDInsight
Enterprise Data Workflows with Cascading and Windows Azure HDInsight
 
Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
 
Avro
AvroAvro
Avro
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4j
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational Databases
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
Hadoop with Python
Hadoop with PythonHadoop with Python
Hadoop with Python
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
Gerry McNicol Graph Databases
Gerry McNicol Graph DatabasesGerry McNicol Graph Databases
Gerry McNicol Graph Databases
 
Apache Spark 101 - Demi Ben-Ari - Panorays
Apache Spark 101 - Demi Ben-Ari - PanoraysApache Spark 101 - Demi Ben-Ari - Panorays
Apache Spark 101 - Demi Ben-Ari - Panorays
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
 

NoSQL, Neo4J for Java Developers , OracleWeek-2012

  • 1. Seminar BigData, NoSQL graph database for Java developers* Presenter: Evgeny Hanikblum
  • 2. Data is getting bigger: “Every 2 days we create as much information as we did up to 2003” – Eric Schmidt, Google
  • 3.
  • 7. Key Value Stores • Most Based on Dynamo: Amazon Highly Available Key-Value Store • Data Model: – Global key-value mapping – Big scalable HashMap – Highly fault tolerant (typically) • Projects:
  • 8. Key Value Stores • Pros: – Simple data model – Scalable • Cons – Create your own “foreign keys” – Poor for complex data
  • 9. Column Databases • Most Based on BigTable: Google’s Distributed Storage System for Structured Data • Data Model: – A big table, with column families – Map Reduce for querying/processing • Projects:
  • 10. Column Databases • Pros: – Supports Simi-Structured Data – Naturally Indexed (columns) – Scalable • Cons – Poor for interconnected data
  • 11. Document Databases • Data Model: – A collection of documents – A document is a key value collection – Index-centric, lots of map-reduce • Projects :
  • 12. Document Databases • Pros: – Simple, powerful data model – Scalable • Cons – Poor for interconnected data – Query model limited to keys and indexes – Map reduce for larger queries
  • 13. Graph Databases • Data Model: – Nodes and Relationships • Projects:
  • 14. Graph Databases • Pros: – Powerful data model, as general as RDBMS – Connected data locally indexed – Easy to query • Cons – Sharding ( lots of people working on this) • Scales UP reasonably well – Requires rewiring your brain
  • 15. Why you need GraphDB ?
  • 16. GraphDB Overview Because of Data expanded into relationships
  • 17. GraphDB Overview Because of Data became interconnected
  • 18. When should I use it ?
  • 19. Use graph db, if you should deal with something like this :
  • 22. GraphDB Overview Data is more connected: • Text (content) • HyperText (added pointers) • RSS (joined those pointers) • Blogs (added pingbacks) • Tagging (grouped related data) • RDF (described connected data) • GGG (content + pointers + relationships + descriptions)
  • 23. GraphDB Overview Data is less structured: • If you tried to collect all the data of every movie ever made, how would you model it? • Actors, Characters, Locations, Dates, Costs, Ratings, Showings, Ticket Sales, etc.
  • 25. What is Graph • An abstract representation of a set of objects where some pairs are connected by links. Object (Vertex, Node) Link (Edge, Arc, Relationship)
  • 26. Different Kinds of Graphs • Undirected Graph • Directed Graph • Pseudo Graph • Multi Graph • Hyper Graph
  • 27. More Kinds of Graphs • Weighted Graph • Labeled Graph • Property Graph
  • 29. What is a Graph DB? • A database with an explicit graph structure • Each node knows its adjacent nodes • As the number of nodes increases, the cost of a local step (or hop) remains the same • Plus an Index for lookups
  • 30. Compared to Relational Databases Optimized for aggregation Optimized for connections
  • 32. What is Neo4j? • A java based graph database • Property Graph • Full ACID (atomicity, consistency, isolation, durability) • High Availability (with Enterprise Edition) • 32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties • Embedded Server • REST API
  • 33. What is Neo4j? • Both nodes and relationships can have metadata. • Integrated pattern-matching-based query language (“Cypher”). • Also the “Gremlin” graph traversal language can be used. • Indexing of nodes and relationships. (Lucene) • Nice self-contained web admin. • Advanced path-finding with multiple algorithms. • Optimized for reads. • Has transactions (in the Java API) • Scriptable in Groovy • Online backup, advanced monitoring and High Availability is AGPL/commercial licensed
  • 34. Neo4j is good for : • Highly connected data (social networks) • Recommendations (e-commerce) • Path Finding (how do I know you?) • A* (Least Cost path) • Data First Schema (bottom-up, but you still need to design)
  • 35. how do I know you?
  • 36. how can I get there ?
  • 37. If you’ve ever • Joined more than 7 tables together • Modeled a graph in a table • Written a recursive CTE • Tried to write some crazy stored procedure with multiple recursive self and inner joins You should use Neo4j
  • 38. rewiring you brain Language LanguageCountry Country language_code language_code country_code language_name country_code country_name word_count primary flag_uri Language Country name name IS_SPOKEN_IN code code word_count as_primary flag_uri
  • 39. rewiring you brain name: “Canada” languages_spoken: “[ „English‟, „French‟ ]” language:“English” spoken_in name: “USA” name: “Canada” language:“Frech” spoken_in name: “France”
  • 40. rewiring you brain Country name flag_uri language_name number_of_words yes_in_langauge no_in_language currency_code Country Language name name flag_uri number_of_words SPEAKS yes no Currency code name
  • 41. show me the code! GraphDatabaseService graphDb = new EmbeddedGraphDatabase("var/neo4j"); Node david = graphDb.createNode(); Node andreas = graphDb.createNode(); david.setProperty("name", "David Montag"); andreas.setProperty("name", "Andreas Kollegger"); Relationship presentedWith = david.createRelationshipTo(andreas, PresentationTypes.PRESENTED_WITH); presentedWith.setProperty("date", System.currentTimeMillis());
  • 45. console.neo4j.org Try it right now: start n=node(*) match n-[r:LOVES]->m return n, type(r), m Notice the two nodes in red, they are your result set.
  • 47. Spring-Data-Neo4J • Focus on Spring Data Neo4j • VMWare is collaborating with Neo Technology, the company behind the Neo4j graph database. • Improved programming model: Annotation-based programming model for applications with rich domain models • Cross-store persistence: Extend existing JPA application with NoSQL persistence • Tagging (grouped related data) • RDF (described connected data)
  • 48. Spring-Data-Neo4J @NodeEntity @NodeEntity public class Actor { private String name; private int age; private HairColor hairColor; private transient String nickname; }
  • 49. Spring-Data-Neo4J @NodeEntity public class Movie { @GraphId Long id; @Indexed(type = FULLTEXT, indexName = "search") String title; Person director; @RelatedTo(type="ACTS_IN", direction = INCOMING) Set<Person> actors; @RelatedToVia(type = "RATED") Iterable<Rating> ratings; @Query("start movie=node({self}) match movie-->genre<--similar return similar") Iterable<Movie> similarMovies; }
  • 50. Spring-Data-Neo4J @RelationshipEntity @RelationshipEntity public class Role { @StartNodeprivate Actor actor; @EndNodeprivate Movie movie; privateString roleName; }
  • 51. Spring-Data-Neo4J @RelationshipEntity public class Role { @StartNode private Actor actor; @EndNode private Movie movie; private String roleName; } @NodeEntity public class Actor { @RelatedToVia(type = “ACTS_IN”) private Iterable<Role> roles; }
  • 52. How they did that ?
  • 53. NoSql->Graph DB->Neo4J Lecturer : Evgeny Hanikblum @ AlphaCSP:OracleWeek2012:Israel Email : evgenyh@alphacsp.com

Hinweis der Redaktion

  1. An undirected graph is one in which edges have no orientation. The edge (a, b) is identical to the edge (b, a).A directed graph or digraph is an ordered pair D = (V, A)A pseudo graph is a graph with loopsA multi graph allows for multiple edges between nodesA hyper graph allows an edge to join more than two nodes
  2. An undirected graph is one in which edges have no orientation. The edge (a, b) is identical to the edge (b, a).A directed graph or digraph is an ordered pair D = (V, A)A pseudo graph is a graph with loopsA multi graph allows for multiple edges between nodesA hyper graph allows an edge to join more than two nodes
  3. Best used: For graph-style, rich or complex, interconnected data. Neo4j is quite different from the others in this sense.For example: Social relations, public transport links, road maps, network topologies.