Top Banner
OrientDB graph database in practice Aurelijus Banelis
22

OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Feb 25, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

OrientDBgraph database

in practice

Aurelijus Banelis

Page 2: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

About me

Aurelijus Banelis

[email protected]

Software Engineer at NFQ

2About

Page 3: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

You will learn

3In short

WHATGraph

Graph database

WHYReal worldexample

HOWWith PHP

With relational databaseBest practice

Page 4: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

WHAT: Graph

4What

Source: http://commons.wikimedia.org/wiki/File:Tiskevicius_Juozapas_1835-1891.JPG

Not Graf mathematical graphRead more at: http://en.wikipedia.org/wiki/Graph_%28mathematics%29

Page 7: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Graph database is optimized for many relations

7WhatRead more at:http://www.orientechnologies.com/docs/last/orientdb.wiki/Tutorial-Relationships.html

http://youtu.be/U0dB7DRXv-I?list=PLxBRkBr-uobtojUxJarvGddSgGJ6KkI85

Page 8: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Summary (1/3)

8

WHATGraph

Graph database

WHYReal worldexample

HOWWith PHP

With relational databaseBest practice

GraphVertices and edgesAs data visualization

Graph databaseOptimized for many relations

What

Page 11: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

WHAT:

11WHY

License: Apache 2 (free + for commercial)

Structures: Schema-hybrid, with extend

Scalability: Sharding, replication, WAL

Used by: Cisco, Ericsson

API: JavaLib, binary, REST

Query languages:WEB, SQL, Gremlin

Storage:File, memory, remote

Documentation:Tutorials, groups, source

Transactions:ACID, MVCC

Attributes:Read-only, metadata

Results:Synchronous, asynchronous

Text search:Lucene full text index

Page 12: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

12WHY

Time for

DEMO

Page 13: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Summary (2/3)

13

WHATGraph

Graph database

WHYReal worldexample

HOWWith PHP

With relational databaseBest practice

Structures/OperationsTrees with cycles = graphTraverse like operations

ToolsDebugging complex structures

Business logicList or association based

WHY

Page 14: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: Notes for developers

14

PHPOrientDB in PHP world

How

Migrationand learning cost

Relationaldatabase integration

Designstructures in database

Page 15: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: in PHP world

15How

PhpOrient "require": { "ostico/phporient": "1.1.*" }

Official PHP >=5.4 OrientDB >=1.7.4

OrientDB-PHP "require": { "orientdb-php/orientdb-php": "dev-master" }

First/oldPHP >=5.3 API getting outdated

OrientDB ODM "require": { "sgpatil/orientdb-odm": "dev-master" } "require": { "concept-it/orient-db-bundle": "dev-master" }

DoctrineSymfonyPHP >=5.3 On top of OrientDB-PHP

REST/HTTP API http://0.0.0.0:2480Slower

OrientDB-PHP

Not recommendNo complex results = no graph

Use PhpOrient instead

Page 16: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: PhpOrient

16How

/** @var Record[] $results */$results = $client->query(  'SELECT FROM Testas WHERE c.d.e = 132');foreach ($results as $res) {  print "{$res->getRid()} {$res['c']['d']['f']}";}

/** @var Bag $inParent */ /** @var ID $id */$inParent = $res['in_Parent'];foreach ($inParent as $id) {   $child = $client->recordLoad($id);}

Page 17: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: Migration costs

17How

* Based on time used in my personal project

Other tasksOrientDBLearningCodingDebugging

Page 18: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: Integrate with relational database

18How

OrientDB ETLNative tool to importToo hard for n-n relations

SQL Batch Execute multiple queries at the server side

LET v1 = CRAETE VERTEX Article SET name="123"LET v2 = CRAETE VERTEX Action SET name="456"LET v3 = CRAETE VERTEX Stock SET house="A", amount=2CREATE EDGE Discount FROM $v1 TO $v2CREATE EDGE Contains FROM $v3 TO $v1

RETURN [$v1, $v2, $v3]

Page 19: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

HOW: Design structure in database

19How

Where to put parameters?

Only in vertices

In edges●Not shown in Graph view●Strange Traverse behavior

●Easier to implement caching●Easier to extend relations●Imitating edge parameter with inheritance of vertices

Page 20: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Summary (3/3)

20

WHATGraph

Graph database

WHYReal worldexample

HOWWith PHP

With relational databaseBest practice

PHP wrapperPhpOrient

Migration costTime for debugging/tests

Relational databaseUse SQL Batch

Design databaseUse light edges

How

Page 21: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

Questions?

?

WHATGraph

Graph database

WHYReal worldexample

HOWWith PHP

With relational databaseBest practice

Page 22: OrientDB: graph database in practiceaurelijus.banelis.lt/prezentations/orientdb-2015/orient...Summary (2/3) 13 WHAT Graph Graph database WHY Real world example HOW With PHP With relational

References and useful links

22i

●http://www.orientechnologies.com ●https://github.com/orientechnologies/orientdb/wiki/SQL-Functions●https://github.com/orientechnologies/orientdb/wiki/SQL-Traverse●http://www.orientechnologies.com/docs/last/orientdb.wiki/Programming-Language-Bindings.html

●https://github.com/orientechnologies/orientdb/wiki/Document-Database#prepared-query

●https://github.com/orientechnologies/orientdb/wiki/Fetching-Strategies●http://neo4j.com/●http://auginte.com