orientdb the graph database

54
www.orientechnologies.com 1.0 May 2012

Upload: artemorobets

Post on 10-May-2015

5.207 views

Category:

Self Improvement


7 download

TRANSCRIPT

Page 1: OrientDB the graph database

www.orientechnologies.com

1.0 May 2012

Page 2: OrientDB the graph database

Artem OrobetsSenior Java Developerin ExigenServices1.5 year in Java

OrientDB committer

Andrey LomakinSoftware Architectin ExigenServices6+ years JEE experience

OrientDB committer

Page 3: OrientDB the graph database

OrientDB=

best features of newest NoSQL solutions

+best features of Relational DBMS

+True Graph engine

www.orientechnologies.com

Page 4: OrientDB the graph database

Relationships

are direct linksno Relational JOINS to connect multiple

tables

Load trees and graphs in few ms!www.orientechnologies.com

Page 5: OrientDB the graph database

Complex types

native support for collections, maps (key/value)

and embedded documentsno more additional tables to handle them

www.orientechnologies.com

Page 6: OrientDB the graph database

Schema-mixed

schema with mandatory and optional fields + constraints

the best of schema-less and schema-full modes

www.orientechnologies.com

Page 7: OrientDB the graph database

ACID Transactionsdb.begin();

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

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

www.orientechnologies.com

Page 8: OrientDB the graph database

SQLselect * from employee where name like '%Jay%' and

status=0

www.orientechnologies.com

Page 9: OrientDB the graph database

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 10: OrientDB the graph database

SQL & relationships

select from Account where address.city.country.name = 'Italy'

select from Account where addresses contains (city.country.name = 'Italy')

www.orientechnologies.com

Page 11: OrientDB the graph database

SQL & schema-less

select from Profile where any() like '%Jay%'

select from Stock where all() is not null

www.orientechnologies.com

Page 12: OrientDB the graph database

HTTP RESTfulfirewall friendlyuse it from the web

browseruse it from the ESB (SOA)

www.orientechnologies.com

Page 13: OrientDB the graph database

NativeJSON

www.orientechnologies.com

{ '@rid' = '26:10', '@class' = 'Developer', 'name' : 'Luca', 'surname' : 'Garulli', 'out' : [ #10:33, #10:232 ]}

Page 14: OrientDB the graph database

Binary protocolavailable for Java

and soon C, C++ and Ruby

www.orientechnologies.com

Page 15: OrientDB the graph database

MVRB-Tree indexthe best of B+Tree and RB-Tree

fast on browsing, low insertion cost

www.orientechnologies.com

Page 16: OrientDB the graph database

Hookssimilar to triggers

catch events against records, database and transactions

implement custom cascade deletion

algorithm

enforce constraints

www.orientechnologies.com

Page 17: OrientDB the graph database

Securityusers and roles, encrypted

passwordsfine grain privileges

www.orientechnologies.com

Page 18: OrientDB the graph database

Multi-Master architecture

any node can read/write to the database

this scale up horizontly

adding nodes is straightforward

Page 19: OrientDB the graph database

Leader Node

The actors

Any server node in the cluster. Has a permanentconnection to the Leader Node

Synchronous mode replication.

Asynchronous mode replication.

Peer Node

Only 1 per Leader per cluster, checks other nodes andnotify changes to other Peer Nodes.

Clients are connected to Server Nodes no matter if Leaderor Peer

Client

Database Database, where data are stored

Page 20: OrientDB the graph database

Cluster auto-discoveringAt start up each Server Node sends a IP Multicast message in broadcast

todiscover if any Leader Node is available to join the cluster.

DBDBDBDBDBDB

DBDBDBDBDBDB

Server #1

(Leader)

Server #2

(Peer)

Page 21: OrientDB the graph database

One Leader Multiple PeersThe first node to start is always the Leader but in case of failure can be

electedany other.

DBDBDBDBDBDB

DBDBDBDBDBDBDBDBDBDBDB

Server #1

(Leader)

Server #2

(Peer)

Server #3

(Peer)

Page 22: OrientDB the graph database

SecurityTo join a cluster the Server Node has to configure the cluster name

and passwordBroadcast messages are encrypted using the password

DBDBDBDBDBDB

Server #1

(Leader)

Server #2

(Peer)

Join the clusterONLY

If knows the nameand password

Page 23: OrientDB the graph database

Multiple clustersMultiple separate clusters can coexist in the same network

Clusters can't see each others. Are separated boxesWhat identify a cluster is name + password

Server #1

(Leader)Server #2

(Peer)Server

#3(Peer)

Cluster 'A', password 'aaa'

Server #1

(Leader)Server #2

(Peer)Server

#3(Peer)

Cluster 'B', password 'bbb'

Page 24: OrientDB the graph database

Synchronous ReplicationGuarantees two databases are always consistent

More expensive than asynchronous

Server #1

Server #2

DB-1 DB-2

Page 25: OrientDB the graph database

Synchronous Replicationsteps

Server #1

DB-2

Server #2

1) Update record request

2) Update record to DB-1

3) Propagates the update

5) Sends back OK to Server #1 4) update record to DB-2

Client #1

6) Sends back OK to Client #1

DB-1

Page 26: OrientDB the graph database

Asynchronous ReplicationChanges are propagated without waiting for the

answerTwo databases could be not consistent in the range

of few ms

Server #1

Server #2

DB-1 DB-2

Page 27: OrientDB the graph database

Asynchronous Replicationsteps

(4a and 4b are executed in parallel)

Server #1

Client #1

1) Update record request

2) Update record to DB-1

3) Propagates the update

4b) update record to DB-2

4a) Sends back OK to Client #1

DB-2

Server #2

DB-1

Page 28: OrientDB the graph database

Conflict ManagementThe conflicts resolution strategy can be

plugged by providing implementations of the OReplicationConflictResolver interface

DB-2

Server #2

Conflict Strategy

Page 29: OrientDB the graph database

Conflict ManagementDefault strategy

DB-2

Server #2

Conflict Log

Default implementation:Conflict mark is createdand conflict should be

resolved manually

DefaultConflict Strategy

Page 30: OrientDB the graph database

Graph Database model

wrapper on top of Document Database

Few simple concepts: Vertex, Edge,

Property and Indexwww.orientechnologies.com

Page 31: OrientDB the graph database

www.orientechnologies.com

OGraphDatabaseNative, damn fast, not the most beautiful

API

2 different API

OrientGraphTinkerPop Blueprints, slowest but:

common to other impls, Gremlin, SPARQL

All APIsare compatibleamong them!So use the right one

for the right case

Page 32: OrientDB the graph database

TinkerPop technologies

sort of “standard” for GraphDBa lot of free open-source projects

http://tinkerpop.com

www.orientechnologies.com

Page 33: OrientDB the graph database

TinkerPop Blueprintsbasic API to interact with GraphDB

implements transactional andindexable property graph model

bidirectional edges

www.orientechnologies.com

Page 34: OrientDB the graph database

TinkerPop Gremli

scripting language

easy to learn and understandUsed for operations against graphs

www.orientechnologies.com

Page 35: OrientDB the graph database

g.v(89).outE('followed_by').inV.outE('sung_by')

.inV.has('name','Garcia').back(3).name

Page 36: OrientDB the graph database

www.orientechnologies.com

OgraphVertex (V)

PersonAddress : Address

Inheritance

Customer

totSold : float

Provider

totBuyed : float

OgraphEdge (E)

Works

since : Date

Resides

since : Date

till : Date

Knows

Level : LEVELS

Vehiclebrand : BRANDS

Page 37: OrientDB the graph database

Polymorphic SQL Query

List<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 38: OrientDB the graph database

Fetch plansChoose what to fetch on query and vertexes/edges

loadingVertexes/Edges not fetched will be lazy-loaded on

requestOptimizes network latency

www.orientechnologies.com

Page 39: OrientDB the graph database

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= *:1

Page 40: OrientDB the graph database

Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]

www.orientechnologies.com

Load root + address= *:1 lives:2

Page 41: OrientDB the graph database

Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]

www.orientechnologies.com

Load root + all known= *:1 knows:1

Page 42: OrientDB the graph database

Fetch plansVertex Luca | | lives city +---------> Vertex ------------> Vertex | 10th street Italy | knows +--------->* [Vertex Vertex Vertex ] [ Marko John Nicholas]

www.orientechnologies.com

Load up 3rd level of depth= *:3

Page 43: OrientDB the graph database

ConsoleORIENT database v.1.0.0 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

> quitwww.orientechnologies.com

Page 44: OrientDB the graph database

OrientDB Studio/SQL query

www.orientechnologies.com

Resultset is editable andchanges are immediately

persistent!

Page 45: OrientDB the graph database

OrientDB Studio/View graph

www.orientechnologies.com

Page 46: OrientDB the graph database

Upcoming featuresNew hash Indexes,

query performance boost,

data consistency check,

new transaction lock mechanics,

object DB improvements

Page 47: OrientDB the graph database

Production usage

Finance Solutions Of America

Page 48: OrientDB the graph database

NuvolaBase.com(b

eta)

www.orientechnologies.com

The firstGraph

Databaseon the Cloud

always availablefew seconds to setup

ituse it from app &

mobile

Page 49: OrientDB the graph database

User’s reasons to chose Only one graph DB with cloud computing

support, high flexibility of data format, powerful data analyzes (SQL + Gremlin), JDBC driver, huge reduction of integration

time, good technical support.

Page 50: OrientDB the graph database

Module OrientDB Neo4j DEX

Release 1.0-SNAPSHOT 1.7M03 4.5.1

VertexTestSuite 11,628.98 30,535.02 4,686.65

EdgeTestSuite 7,712.06 41,206.89 58,671.90

GraphTestSuite 9,073.09 55,102.35 7,428.25

IndexableGraphTestSuite 4,620.61 11,299.02 1070.75

IndexTestSuite 2,072.23 5,239.92 not supported

AutomaticIndexTestSuite 3,252.48 9,402.59 not supported

TransactionGraphTestSuite 7,659.67 22,787.29 not supported

GraphMLReaderTestSuite 4,064.23 5,440.67 not supported

Blueprints microbenchmarks

git clone git://github.com/tinkerpop/blueprints.git mvn clean install

Page 51: OrientDB the graph database

Always

FreeOpen Source Apache 2

licensefree for any purposes,

even commercialswww.orientechnologies.com

Page 52: OrientDB the graph database

No dependencieswith 3rd parties software

no conflicts with other software

just 1 Mb of run-time libraries

www.orientechnologies.com

Page 53: OrientDB the graph database

Ø configdownload, unzip, run!

cut & paste the dbwww.orientechnologies.com

Page 54: OrientDB the graph database

Luca GarulliFounder of OrientDB

Andrey LomakinCommitter of OrientDB

Artem OrobetsCommiter of OrientDB

www.orientechnologies.com

@lgarulli,@Andrey_Lomakin,

@Dr_EniSh