works with persistent graphs using orientdb

65

Click here to load reader

Upload: graphdevroom

Post on 10-May-2015

7.222 views

Category:

Technology


2 download

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 tool

TRANSCRIPT

Page 1: Works with persistent graphs using OrientDB
Page 2: Works with persistent graphs using OrientDB

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

The database for graphs

Page 4: Works with persistent graphs using OrientDB

+12 yearsof research

www.orientechnologies.com

Page 5: Works with persistent graphs using OrientDB

+2 yearsof design and develop

www.orientechnologies.com

Page 6: Works with persistent graphs using OrientDB

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

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

Ø configdownload, unzip, run!

cut & paste the db

www.orientechnologies.com

Page 9: Works with persistent graphs using OrientDB

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

Java®

runs everywhere is available JRE1.5+

robust engine

www.orientechnologies.com

Page 11: Works with persistent graphs using OrientDB

150,000records per second

www.orientechnologies.com

Page 12: Works with persistent graphs using OrientDB

Schema-lessschema is not mandatory, relaxed model,

collect heterogeneous documents all together

www.orientechnologies.com

Page 13: Works with persistent graphs using OrientDB

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

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

ACID Transactionsdb.begin();

try{ // your code ... db.commit();

} catch( Exception e ) { db.rollback();}

www.orientechnologies.com

Page 16: Works with persistent graphs using OrientDB

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

SQLselect * from employee where name like '%Jay%' and status=0

www.orientechnologies.com

Page 18: Works with persistent graphs using OrientDB

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Import/Exportuses JSON format

online operations (don't stop the database)

www.orientechnologies.com

Page 33: Works with persistent graphs using OrientDB

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

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

Securityusers and roles, encrypted passwords

fine grain privileges

www.orientechnologies.com

Page 36: Works with persistent graphs using OrientDB

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

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

OrientDB Studio/SQL query

www.orientechnologies.com

Page 39: Works with persistent graphs using OrientDB

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

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

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

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

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

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

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

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

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

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

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

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

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
Page 53: Works with persistent graphs using OrientDB

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
Page 55: Works with persistent graphs using OrientDB

www.orientechnologies.com

Graph example

Page 56: Works with persistent graphs using OrientDB
Page 57: Works with persistent graphs using OrientDB
Page 58: Works with persistent graphs using OrientDB

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

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

Always FreeOpen Source Apache 2 license

free for any purposes,even commercials

www.orientechnologies.com

Page 61: Works with persistent graphs using OrientDB

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

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

Certification Programto be part of the network

do coursesshare revenues for support

work as consultant

www.orientechnologies.com

[email protected]

Page 64: Works with persistent graphs using OrientDB
Page 65: Works with persistent graphs using OrientDB

Luca MolinoCommitter of OrientDB andRoma <Meta> Framework

Open Source projects,

Software Architect at Asset Data

www.orientechnologies.com

www.twitter.com/MaDaPHaKa@Rome, Italy