Works with persistent graphs using OrientDB

8,924 views
8,683 views

Published on

This talk will present OrientDB open source project and its capability to handle persistent graphs in different ways. OrientDB presentation Java Graph Native API SQL+graph extensions HTTP API Blueprints API Gremlin usage Console tool Studio web tool

Published in: Technology

Works with persistent graphs using OrientDB

  1. 1. Can I have a fast GraphDBwith flexible schema, ACID Transactions,SQL support, Security all for FREE?? www.orientechnologies.com
  2. 2. The database for graphs
  3. 3. +12 years of research www.orientechnologies.com
  4. 4. +2 yearsof design and develop www.orientechnologies.com
  5. 5. OrientDB =best features of newest NoSQL solutions + best features of Relational DBMS + True Graph engine www.orientechnologies.com
  6. 6. Relationships are direct linksno Relational JOINS to connect multiple tables Load trees and graphs in few ms! www.orientechnologies.com
  7. 7. Ø config download, unzip, run! cut & paste the db www.orientechnologies.com
  8. 8. No dependencies rd with 3 parties softwareno conflicts with other software just 1 Mb of run-time libraries www.orientechnologies.com
  9. 9. ®runs Java everywhere is available JRE1.5+ robust engine www.orientechnologies.com
  10. 10. 150,000 records per second www.orientechnologies.com
  11. 11. Schema-less schema is not mandatory, relaxed model,collect heterogeneous documents all together www.orientechnologies.com
  12. 12. Schema-fullschema with constraints on fields and validation rulesCustomer.age > 17Customer.address not nullCustomer.surname is mandatoryCustomer.email matches b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}b www.orientechnologies.com
  13. 13. Schema-mixedschema with mandatory and optional fields + constraints the best of schema-less and schema-full modes www.orientechnologies.com
  14. 14. ACID Transactionsdb.begin();try{ // your code ... db.commit();} catch( Exception e ) { db.rollback();} www.orientechnologies.com
  15. 15. Complex types collections, maps (key/value)native support for and embedded documents no more additional tables to handle them www.orientechnologies.com
  16. 16. SQLselect * from employee where name like %Jay% and status=0 www.orientechnologies.com
  17. 17. Why reinvent yet another language whenthe 100% of developers already knows SQL? OrientDB begins from SQL but improve it with newoperators for graph manipulation www.orientechnologies.com
  18. 18. For the most of the querieseveryday a programmer needs SQL is simpler, more readable and compact then Scripting (Map/Reduce) www.orientechnologies.com
  19. 19. SELECT SUM(price) as prices, SUM(cost) as costs, prices-costs, margin/price FROM Balance VSfunction (key, values) { var price = 0.0, cost = 0.0, margin = 0.0, marginPercent = 0.0; for (var i = 0; i < values.length; i++) { price += values[i].price; cost += values[i].cost; } margin = price - cost; marginPercent = margin / price; return { price: price, cost: cost, margin: margin, marginPercent: marginPercent };} www.orientechnologies.com
  20. 20. Asynchronous Queryinvoke callback when a record matches the condition doesnt collect the result set perfect for immediate results useful to compute aggregates www.orientechnologies.com
  21. 21. Enhanced SQLSQL is not enough for collections, maps, trees and graphs need to enhance SQL syntax Easy syntax derived from JDO/JPA standards www.orientechnologies.com
  22. 22. SQL & relationshipsselect from Account where address.city.country.name = Italyselect from Account where addresses contains (city.country.name = Italy) www.orientechnologies.com
  23. 23. SQL & stringsselect from Profile where name.toUpperCase() = LUCAselect from City where country.name.substring(1,3).toUpperCase() = TALselect from Agenda where phones contains ( number.indexOf( +39 ) > -1 )select from Agenda where email matches bA-Z0-9._%+-?+@A-Z0-9.-?+.A-Z?{2,4}b www.orientechnologies.com
  24. 24. SQL & schema-lessselect from Profile where any() like %Jay%select from Stock where all() is not null www.orientechnologies.com
  25. 25. SQL & collectionsselect from Tree where children contains ( married = true )select from Tree where children containsAll ( married = true )select from User where roles containsKey shutdownselect from Graph where edges.size() > 0 www.orientechnologies.com
  26. 26. Binary protocolFast compressed JSON over tcp/ip available for Java and soon C, C++ and Ruby www.orientechnologies.com
  27. 27. Language bindings Java as nativeJRuby, Scala and Javascript readyC, C++, Ruby, Node.js in progress www.orientechnologies.com
  28. 28. Your language isnot supported (yet)? Write an adapter using the C, Java or HTTP binding www.orientechnologies.com
  29. 29. HTTP RESTful firewall friendlyuse it from the webbrowser use it from the ESB (SOA) www.orientechnologies.com
  30. 30. Native JSON{ @rid = 26:10, @class = Developer, name : Luca, surname : Garulli, outEdges : [ #10:33, #10:232 ]} www.orientechnologies.com
  31. 31. Import/Export uses JSON formatonline operations (dont stop the database) www.orientechnologies.com
  32. 32. RB+Tree index the best of B+Tree and RB-Treefast on browsing, low insertion cost Its a new algorithm (soon public) www.orientechnologies.com
  33. 33. Hooks similar to triggerscatch events against records, database and transactions implement custom cascade deletion algorithm enforce constraints www.orientechnologies.com
  34. 34. Securityusers and roles, encrypted passwords fine grain privileges www.orientechnologies.com
  35. 35. Multi-Master Clustering Hight-Availability Cluster of distributed server nodes Synchronous, Asynchronous and Read-Only replication Load-balancing between client ↔ servers and Servers ↔ Servers www.orientechnologies.com
  36. 36. ConsoleORIENT database v.0.9.23 www.orientechnologies.comType help to display all the commands supported.> connect remote:localhost/demo admin adminConnecting to database [remote:localhost/demo] with user admin...OK> select from profile where nick.startsWith(L)---+--------+--------------------+--------------------+--------------------+ #| REC ID |NICK |SEX |AGE |---+--------+--------------------+--------------------+--------------------+ 0| 10:0|Lvca |male |34 1| 10:3|Leo |male |22 2| 10:7|Luisa |female |273 item(s) found. Query executed in 0.013 sec(s).> closeDisconnecting from the database [demo]...OK> quit www.orientechnologies.com
  37. 37. OrientDB Studio/SQL query www.orientechnologies.com
  38. 38. Graph Database model wrapper on top of Document DatabaseFew simple concepts: Vertex, Edge, Property and Index www.orientechnologies.com
  39. 39. Inheritance OGraphVertex OGraphEdge Person Vehicle Works Resides Knows Address : Address brand : BRANDS since : Date since : Date till : Date Level : LEVELSCustomer ProvidertotSold : float totBuyed : float www.orientechnologies.com
  40. 40. Polymorphic SQL QueryList<ODocument> result = database.query( new OSQLSynchQuery( "select from Person where city.name = Rome" )); Queries are polymorphics and subclasses of Person can be part of result set www.orientechnologies.com
  41. 41. 3 API OGraphDatabaseNative, damn fast, not the most beautiful API All APIs are compatible among them! So use the right one for the right case ODatabaseGraphTx Native, Fluent API OrientGraph TinkerPop Blueprints, slowest but: common to other impls, Gremlin, SPARQL (Sail) www.orientechnologies.com
  42. 42. What to choose? OGraphDatabase Native, damn fast, not the most beautiful APIOGraphDatabase if you need Performance at any cost.Use it for massive insertion or low resources www.orientechnologies.com
  43. 43. What to choose? ODatabaseGraphTx Native, Fluent API ODatabaseGraphTx if you needgood performance and fluent API Use it for all day code www.orientechnologies.com
  44. 44. What to choose? OrientGraph TinkerPop Blueprints, slowest but: common to other impls, Gremlin, SPARQL (Sail) OrientGraph if you want to stay Portableat the cost of speed (the slowest) or to use Gremlin language, or as RDF store + SPARQL www.orientechnologies.com
  45. 45. Fetch plans Choose what to fetch on query and vertexes/edges loadingVertexes/Edges not fetched will be lazy-loaded on request Optimizes network latency www.orientechnologies.com
  46. 46. Fetch plans Load only the root vertexVertex = *:0 Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas] www.orientechnologies.com
  47. 47. Fetch plans Load root + addressVertex = *:0 lives.city:0 Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas] www.orientechnologies.com
  48. 48. Fetch plans Load root + all knownVertex = *:0 knows:1 Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas] www.orientechnologies.com
  49. 49. Fetch plans Load up 2rd level of depthVertex = *:2 Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas] www.orientechnologies.com
  50. 50. TinkerPop technologies sort of “standard” for GraphDB a lot of free open-source projects http://tinkerpop.com www.orientechnologies.com
  51. 51. GraphDB & Blueprints APIOrientGraph graph = new OrientGraph("local:/tmp/db/graph”);Vertex sheldon = graph.addVertex(null);actor.setProperty("name", "Sheldon");actor.setProperty("surname", "Cooper");Vertex leonard = graph.addVertex(null);actor.setProperty("name", "Leonard");actor.setProperty("surname", "Hofstadter");Edge edge = graph.addEdge(null, sheldon, leonard, "annoys");graph.shutdown(); www.orientechnologies.com
  52. 52. Graph example www.orientechnologies.com
  53. 53. SQL TRAVERSEtraverse in from Scientist where $depth <= 2traverse out from 10:1 where $depth <= 5traverse * from (select from Scientist where name = Sheldon) where $depth < 3 www.orientechnologies.com
  54. 54. SQL TRAVERSEselect name from (traverse in from(select from Nailed) where $depth <= 2)where @class <> OGraphEdgeselect in.name as name, in.surname as surname from(traverse out from (select from Commoner where name = Penny) where $depth <= 4) where label = annoys www.orientechnologies.com
  55. 55. Always FreeOpen Source Apache 2 license free for any purposes, even commercials www.orientechnologies.com
  56. 56. Prof€$$ional $€rvic€$ by a network of companies through Orient Technologiessupport, training, consulting, mentoring www.orientechnologies.com
  57. 57. OrientDB OrientDBfor Java developers Master Development 8 hours 14 hours OrientDB OrientDB for SOA and the power of graphs 6 hours 6 hours OrientDB OrientPlanet for DBA for Web Developers 6 hours 6 hours www.orientechnologies.com
  58. 58. Certification Program to be part of the network do courses share revenues for support work as consultant Contactcommercial@orientechnologies.com www.orientechnologies.com
  59. 59. Luca Molino Committer of OrientDB and Roma <Meta> Framework Open Source projects, Software Architect at Asset Datawww.twitter.com/MaDaPHaKa @Rome, Italy www.orientechnologies.com

×