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
12. Schema-less
schema is not mandatory, relaxed model,
collect heterogeneous documents all together
www.orientechnologies.com
13. Schema-full
schema with constraints on fields and validation rules
Customer.age > 17
Customer.address not null
Customer.surname is mandatory
Customer.email matches 'b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}b'
www.orientechnologies.com
14. Schema-mixed
schema with mandatory and optional fields + constraints
the best of schema-less and schema-full modes
www.orientechnologies.com
16. Complex types
collections, maps (key/value)
native support for
and embedded documents
no more additional tables to handle them
www.orientechnologies.com
17. SQL
select * from employee where name like '%Jay%' and status=0
www.orientechnologies.com
18. Why reinvent
yet another language when
the 100% of developers already
knows SQL?
OrientDB begins from SQL
but improve it with new
operators for graph manipulation
www.orientechnologies.com
19. For the most of the queries
everyday a programmer needs
SQL is simpler,
more readable and
compact then
Scripting (Map/Reduce)
www.orientechnologies.com
20. SELECT SUM(price) as prices, SUM(cost) as costs, prices-costs, margin/price
FROM Balance
VS
function (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
21. Asynchronous Query
invoke callback when a record matches the condition
doesn't collect the result set
perfect for immediate results
useful to compute aggregates
www.orientechnologies.com
22. Enhanced SQL
SQL is not enough for collections, maps, trees and graphs
need to enhance SQL syntax
Easy syntax derived from JDO/JPA standards
www.orientechnologies.com
23. SQL & relationships
select from Account where address.city.country.name = 'Italy'
select from Account where addresses contains (city.country.name = 'Italy')
www.orientechnologies.com
24. SQL & strings
select 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._%+-?+@A-Z0-9.-?+.A-Z?{2,4}b'
www.orientechnologies.com
25. SQL & schema-less
select from Profile where any() like '%Jay%'
select from Stock where all() is not null
www.orientechnologies.com
26. SQL & collections
select 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
32. Import/Export
uses JSON format
online operations (don't stop the database)
www.orientechnologies.com
33. RB+Tree index
the best of B+Tree and RB-Tree
fast on browsing, low insertion cost
It's a new algorithm (soon public)
www.orientechnologies.com
34. Hooks
similar to triggers
catch events against records, database and transactions
implement custom cascade deletion algorithm
enforce constraints
www.orientechnologies.com
36. 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
37. Console
ORIENT database v.0.9.23 www.orientechnologies.com
Type 'help' to display all the commands supported.
> connect remote:localhost/demo admin admin
Connecting 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 |27
3 item(s) found. Query executed in 0.013 sec(s).
> close
Disconnecting from the database [demo]...OK
> quit
www.orientechnologies.com
39. Graph Database model
wrapper on top of Document Database
Few simple concepts: Vertex, Edge,
Property and Index
www.orientechnologies.com
40. Inheritance
OGraphVertex OGraphEdge
Person Vehicle Works Resides Knows
Address : Address brand : BRANDS since : Date
since : Date till : Date Level : LEVELS
Customer Provider
totSold : float totBuyed : float
www.orientechnologies.com
41. Polymorphic SQL Query
List<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
42. 3 API
OGraphDatabase
Native, 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
43. What to choose?
OGraphDatabase
Native, damn fast, not the most beautiful API
OGraphDatabase if you need
Performance at any cost.
Use it for massive insertion or
low resources
www.orientechnologies.com
44. What to choose?
ODatabaseGraphTx
Native, Fluent API
ODatabaseGraphTx if you need
good performance and fluent API
Use it for all day code
www.orientechnologies.com
45. What to choose?
OrientGraph
TinkerPop Blueprints, slowest but:
common to other impls, Gremlin, SPARQL (Sail)
OrientGraph if you want to stay
Portable
at the cost of speed (the slowest)
or to use Gremlin language,
or as RDF store + SPARQL
www.orientechnologies.com
46. Fetch plans
Choose what to fetch on query and vertexes/edges loading
Vertexes/Edges not fetched will be lazy-loaded on request
Optimizes network latency
www.orientechnologies.com
47. Fetch plans
Load only the root vertex
Vertex = *:0
Luca
|
| lives city
+---------> Vertex ------------> Vertex
| 10th street Italy
| knows
+--------->* [Vertex Vertex Vertex ]
[ Marko John Nicholas]
www.orientechnologies.com
48. Fetch plans
Load root + address
Vertex = *:0 lives.city:0
Luca
|
| lives city
+---------> Vertex ------------> Vertex
| 10th street Italy
| knows
+--------->* [Vertex Vertex Vertex ]
[ Marko John Nicholas]
www.orientechnologies.com
49. Fetch plans
Load root + all known
Vertex = *:0 knows:1
Luca
|
| lives city
+---------> Vertex ------------> Vertex
| 10th street Italy
| knows
+--------->* [Vertex Vertex Vertex ]
[ Marko John Nicholas]
www.orientechnologies.com
50. Fetch plans
Load up 2rd level of depth
Vertex = *:2
Luca
|
| lives city
+---------> Vertex ------------> Vertex
| 10th street Italy
| knows
+--------->* [Vertex Vertex Vertex ]
[ Marko John Nicholas]
www.orientechnologies.com
51. TinkerPop technologies
sort of “standard” for GraphDB
a lot of free open-source projects
http://tinkerpop.com
www.orientechnologies.com
58. 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
59. SQL TRAVERSE
select 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
60. Always Free
Open Source Apache 2 license
free for any purposes,
even commercials
www.orientechnologies.com
61. Prof€$$ional
$€rvic€$
by a network of companies through
Orient Technologies
support, training, consulting, mentoring
www.orientechnologies.com
62. OrientDB OrientDB
for 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
63. Certification Program
to be part of the network
do courses
share revenues for support
work as consultant
Contact
commercial@orientechnologies.com
www.orientechnologies.com
64.
65. Luca Molino
Committer of OrientDB and
Roma <Meta> Framework
Open Source projects,
Software Architect at Asset Data
www.twitter.com/MaDaPHaKa
@Rome, Italy
www.orientechnologies.com