works with persistent graphs using orientdb
DESCRIPTION
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 toolTRANSCRIPT
![Page 1: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/1.jpg)
![Page 2: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/2.jpg)
www.orientechnologies.com
Can I have a fastGraphDB
with flexible schema,ACID Transactions,
SQL support, Securityall for FREE??
![Page 3: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/3.jpg)
The database for graphs
![Page 4: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/4.jpg)
+12 yearsof research
www.orientechnologies.com
![Page 5: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/5.jpg)
+2 yearsof design and develop
www.orientechnologies.com
![Page 6: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/6.jpg)
OrientDB=
best features of newest NoSQL solutions+
best features of Relational DBMS+
True Graph enginewww.orientechnologies.com
![Page 7: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/7.jpg)
Relationshipsare direct links
no Relational JOINS to connect multiple tables
Load trees and graphs in few ms!
www.orientechnologies.com
![Page 8: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/8.jpg)
Ø configdownload, unzip, run!
cut & paste the db
www.orientechnologies.com
![Page 9: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/9.jpg)
No dependencieswith 3rd parties software
no conflicts with other software
just 1 Mb of run-time libraries
www.orientechnologies.com
![Page 10: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/10.jpg)
Java®
runs everywhere is available JRE1.5+
robust engine
www.orientechnologies.com
![Page 11: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/11.jpg)
150,000records per second
www.orientechnologies.com
![Page 12: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/12.jpg)
Schema-lessschema is not mandatory, relaxed model,
collect heterogeneous documents all together
www.orientechnologies.com
![Page 13: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/13.jpg)
Schema-fullschema with constraints on fields and validation rules
Customer.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
![Page 14: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/14.jpg)
Schema-mixedschema with mandatory and optional fields + constraints
the best of schema-less and schema-full modes
www.orientechnologies.com
![Page 15: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/15.jpg)
ACID Transactionsdb.begin();
try{ // your code ... db.commit();
} catch( Exception e ) { db.rollback();}
www.orientechnologies.com
![Page 16: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/16.jpg)
Complex typesnative support for collections, maps (key/value)
and embedded documentsno more additional tables to handle them
www.orientechnologies.com
![Page 17: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/17.jpg)
SQLselect * from employee where name like '%Jay%' and status=0
www.orientechnologies.com
![Page 18: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/18.jpg)
www.orientechnologies.com
Why reinventyet another language when
the 100% of developers alreadyknows SQL?
OrientDB begins from SQLbut improve it with new
operators for graph manipulation
![Page 19: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/19.jpg)
www.orientechnologies.com
For the most of the querieseveryday a programmer needs
SQL is simpler,more readable and
compact thenScripting (Map/Reduce)
![Page 20: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/20.jpg)
www.orientechnologies.com
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 };}
![Page 21: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/21.jpg)
Asynchronous Queryinvoke callback when a record matches the condition
doesn't collect the result setperfect for immediate results
useful to compute aggregates
www.orientechnologies.com
![Page 22: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/22.jpg)
Enhanced SQLSQL is not enough for collections, maps, trees and graphs
need to enhance SQL syntaxEasy syntax derived from JDO/JPA standards
www.orientechnologies.com
![Page 23: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/23.jpg)
SQL & relationshipsselect from Account where address.city.country.name = 'Italy'
select from Account where addresses contains (city.country.name = 'Italy')
www.orientechnologies.com
![Page 24: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/24.jpg)
SQL & stringsselect from Profile where name.toUpperCase() = 'LUCA'
select from City where country.name.substring(1,3).toUpperCase() = 'TAL'
select from Agenda where phones contains ( number.indexOf( '+39' ) > -1 )
select from Agenda where email matches '\bA-Z0-9._%[email protected]?+\.A-Z?{2,4}\b'
www.orientechnologies.com
![Page 25: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/25.jpg)
SQL & schema-lessselect from Profile where any() like '%Jay%'
select from Stock where all() is not null
www.orientechnologies.com
![Page 26: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/26.jpg)
SQL & collectionsselect from Tree where children contains ( married = true )
select from Tree where children containsAll ( married = true )
select from User where roles containsKey 'shutdown'
select from Graph where edges.size() > 0
www.orientechnologies.com
![Page 27: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/27.jpg)
Binary protocolFast compressed JSON over tcp/ip
available for Javaand soon C, C++ and Ruby
www.orientechnologies.com
![Page 28: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/28.jpg)
Language bindingsJava as native
JRuby, Scala and Javascript readyC, C++, Ruby, Node.js in progress
www.orientechnologies.com
![Page 29: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/29.jpg)
Your language isnot supported (yet)?
Write an adapter using theC, Java or HTTP binding
www.orientechnologies.com
![Page 30: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/30.jpg)
HTTP RESTfulfirewall friendly
use it from the web browseruse it from the ESB (SOA)
www.orientechnologies.com
![Page 31: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/31.jpg)
Native JSON{ '@rid' = '26:10', '@class' = 'Developer', 'name' : 'Luca', 'surname' : 'Garulli', 'outEdges' : [ #10:33, #10:232 ]}
www.orientechnologies.com
![Page 32: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/32.jpg)
Import/Exportuses JSON format
online operations (don't stop the database)
www.orientechnologies.com
![Page 33: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/33.jpg)
RB+Tree index
the best of B+Tree and RB-Treefast on browsing, low insertion costIt's a new algorithm (soon public)
www.orientechnologies.com
![Page 34: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/34.jpg)
Hookssimilar to triggers
catch events against records, database and transactions
implement custom cascade deletion algorithmenforce constraints
www.orientechnologies.com
![Page 35: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/35.jpg)
Securityusers and roles, encrypted passwords
fine grain privileges
www.orientechnologies.com
![Page 36: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/36.jpg)
Multi-Master ClusteringHight-Availability
Cluster of distributed server nodesSynchronous, Asynchronous and Read-Only
replicationLoad-balancing between client servers and↔
Servers Servers↔
www.orientechnologies.com
![Page 37: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/37.jpg)
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
![Page 38: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/38.jpg)
OrientDB Studio/SQL query
www.orientechnologies.com
![Page 39: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/39.jpg)
Graph Database modelwrapper on top of Document Database
Few simple concepts: Vertex, Edge,Property and Index
www.orientechnologies.com
![Page 40: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/40.jpg)
www.orientechnologies.com
OGraphVertex
PersonAddress : Address
Inheritance
CustomertotSold : float
ProvidertotBuyed : float
OGraphEdge
Works
since : Date
Residessince : Datetill : Date
Knows
Level : LEVELS
Vehiclebrand : BRANDS
![Page 41: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/41.jpg)
Polymorphic SQL QueryList<ODocument> result = database.query( new OSQLSynchQuery(
"select from Person where city.name = 'Rome'" ));
www.orientechnologies.com
Queries are polymorphicsand subclasses of Person can be
part of result set
![Page 42: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/42.jpg)
www.orientechnologies.com
OGraphDatabaseNative, damn fast, not the most beautiful API
ODatabaseGraphTxNative, Fluent API
3 API
OrientGraphTinkerPop Blueprints, slowest but:
common to other impls, Gremlin, SPARQL (Sail)
All APIsare compatibleamong them!
So use the right onefor the right case
![Page 43: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/43.jpg)
www.orientechnologies.com
OGraphDatabaseNative, damn fast, not the most beautiful API
What to choose?
OGraphDatabase if you needPerformance at any cost.
Use it for massive insertion orlow resources
![Page 44: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/44.jpg)
www.orientechnologies.com
What to choose?
ODatabaseGraphTx if you needgood performance and fluent API
Use it for all day code
ODatabaseGraphTxNative, Fluent API
![Page 45: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/45.jpg)
www.orientechnologies.com
What to choose?
OrientGraph if you want to stayPortable
at the cost of speed (the slowest)
or to use Gremlin language,or as RDF store + SPARQL
OrientGraphTinkerPop Blueprints, slowest but:
common to other impls, Gremlin, SPARQL (Sail)
![Page 46: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/46.jpg)
Fetch plansChoose what to fetch on query and vertexes/edges loading
Vertexes/Edges not fetched will be lazy-loaded on requestOptimizes network latency
www.orientechnologies.com
![Page 47: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/47.jpg)
Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]
www.orientechnologies.com
Load only the root vertex= *:0
![Page 48: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/48.jpg)
Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]
www.orientechnologies.com
Load root + address= *:0 lives.city:0
![Page 49: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/49.jpg)
Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]
www.orientechnologies.com
Load root + all known= *:0 knows:1
![Page 50: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/50.jpg)
Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]
www.orientechnologies.com
Load up 2rd level of depth= *:2
![Page 51: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/51.jpg)
TinkerPop technologiessort of “standard” for GraphDB
a lot of free open-source projects
http://tinkerpop.com
www.orientechnologies.com
![Page 52: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/52.jpg)
![Page 53: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/53.jpg)
GraphDB & Blueprints API
OrientGraph 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
![Page 54: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/54.jpg)
![Page 55: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/55.jpg)
www.orientechnologies.com
Graph example
![Page 56: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/56.jpg)
![Page 57: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/57.jpg)
![Page 58: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/58.jpg)
SQL TRAVERSE
traverse in from Scientist where $depth <= 2
traverse out from 10:1 where $depth <= 5
traverse * from (select from Scientist where name = 'Sheldon') where $depth < 3
www.orientechnologies.com
![Page 59: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/59.jpg)
SQL TRAVERSEselect name from (traverse in from (select from Nailed) where $depth <= 2) where @class <> 'OGraphEdge'
select 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
![Page 60: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/60.jpg)
Always FreeOpen Source Apache 2 license
free for any purposes,even commercials
www.orientechnologies.com
![Page 61: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/61.jpg)
Prof€$$ional$€rvic€$
by a network of companies throughOrient Technologies
support, training, consulting, mentoring
www.orientechnologies.com
![Page 62: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/62.jpg)
www.orientechnologies.com
OrientDBfor Java developers
8 hours
OrientDBMaster Development
14 hours
OrientDBfor SOA
6 hours
OrientDBand the power of graphs
6 hours
OrientDBfor DBA
6 hours
OrientPlanetfor Web Developers
6 hours
![Page 63: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/63.jpg)
Certification Programto be part of the network
do coursesshare revenues for support
work as consultant
www.orientechnologies.com
![Page 64: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/64.jpg)
![Page 65: Works with persistent graphs using OrientDB](https://reader037.vdocuments.us/reader037/viewer/2022100304/554f62a0b4c905c8088b4b3d/html5/thumbnails/65.jpg)
Luca MolinoCommitter of OrientDB andRoma <Meta> Framework
Open Source projects,
Software Architect at Asset Data
www.orientechnologies.com
www.twitter.com/MaDaPHaKa@Rome, Italy