orientdb introduction - nosql

15
“A NoSQL Database for the Internet age” www.OrienTechnologies.com Author of OrientDB and Roma Framework Open Source projects, CTO at Asset Data company, Technical Manager at Romulus consortium Luca Garulli [email protected] http://zion-city.blogspot.com http://twitter.com/lgarulli Luca Garulli [email protected] http://zion-city.blogspot.com http://twitter.com/lgarulli

Upload: luca-garulli

Post on 10-May-2015

19.309 views

Category:

Technology


2 download

DESCRIPTION

Introduction to OrientDB NoSQL document dbms

TRANSCRIPT

“A NoSQL Database for the Internet age”

www.OrienTechnologies.com

Author of OrientDB and Roma Framework Open Source projects,CTO at Asset Data company, Technical Manager at Romulus consortium

Luca [email protected]://zion-city.blogspot.comhttp://twitter.com/lgarulli

Luca [email protected]://zion-city.blogspot.comhttp://twitter.com/lgarulli

NoSQL movement“In recent years, a number of new systems, sometimes called “NoSQL” systems, have been introduced to provide indexed data storage that is much higher performance than existing relational database products like MySQL, Oracle, DB2, and SQL Server. These data storage systems have a number of features in common:

● A simple call level interface or protocol (in contrast to a SQL binding) ● Ability to horizontally scale throughput over many servers, ● Efficient use of distributed indexes and RAM for data storage, and ● The ability to dynamically define new attributes or data schema“

from “High Performance Scalable Data Stores” by Rick Cattell

For more information visit: http://www.orientechnologies.com

There are two main products released with commercial friendly Open Source Apache 2 license

Products

Deeply scalable Document based DBMS that uses the features of the Graph Databases to handle links. It's the

basic engine of all the Orient products. It can work in schema-less mode, schema-full or a mix of both.

Supports advanced features, such as indexing, fluent and SQL-like queries. It handles natively JSON and XML

documents. Developers can use Java native and HTTP RESTful APIs

Graphs of hundreads of linked objects can be retrieved all in memory in less than 1ms without executing costly JOINs

such as the Relational DBMSs do.

The Key/Value Server based on the Document Database technology and accessible as embedded repository via Java APIs or via HTTP using a

RESTful API. Orient K/V uses a new algorithm called RB+Tree, derived

from the Red-Black Tree and from the B+Tree.

Orient Key/Value server can run in high availability mode using a

cluster of multiple nodes partitioned.

For more information visit: http://www.orientechnologies.com

Database structure

For more information visit: http://www.orientechnologies.com

Cluster concept

Cluster “Twit“Type = physicalCluster “Twit“Type = physicalCluster “OtherProfile“

Type = logicalCluster “OtherProfile“

Type = logical

Cluster “FamousProfile“Type = physical

Cluster “FamousProfile“Type = physical

Bill GatesJay Miner

Class “Profile“Class “Profile“

Class “Profile“ has records distributed on

multiple clusters.

The “FamousProfile“ cluster contains all the profile of the most famous people and it's supposed to being accessed frequently. This

is the reason why we selected “physical“ as type.

All the other profiles will be stored into the “OtherProfile“ cluster of type

“logical“

APIs

OrientDB is written 100% in Java® and can run on any platform that supports the Java® Technology version 5 or

more.

OrientDB supports native Java client API to work with embedded or remote databases using the fast binary

protocol

OrientDB Server comes with a HTTP RESTful interface to being used from any language, even from the Internet

Browser. Uses JSON to represents recordsFor more information visit: http://www.orientechnologies.com

Java example with records// OPEN THE DATABASEODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/demo").open("admin", "admin");

// CREATE A NEW DOCUMENT AND FILL ITODocument doc = new ODocument(db, "Person");doc.field( "name", "Luke" );doc.field( "surname", "Skywalker" );doc.field( "city", new ODocument("City" ).field("name","Rome").field("country", "Italy") ); // SAVE THE DOCUMENTdoc.save();

// QUERY THE DOCUMENTList<ODocument> result = database.query( new OSQLSynchQuery("select * from person where city.name = 'Rome'")).execute();

// PRINT THE RESULT SETfor( ODocument d : result ){ System.out.println("Person: " + d.field( "name" ) + d.field( "surname" ));}

db.close();

This is a relationship Many-to-One

Query using the SQL syntax with

extensions to traverse links without costly

JOINs

For more information visit: http://www.orientechnologies.com

Object Database interfaceEven if OrientDB is not an ODBMS (but is a Document DBMS), it

offers the ODatabaseObject interface to works with POJOs in transparent way removing the Impedence Mismatch problem

Fields not present in the real Java class will be not mapped but saved with the original record

Queries convert automatically records to POJOs

References between POJO can be stored as links (aka relationships) or by including the referenced object as

embedded.

For more information visit: http://www.orientechnologies.com

Java example with POJOs// OPEN THE DATABASEODatabaseObjectTx db = new ODatabaseObjectTx("remote:localhost/demo").open("admin", "admin");

// CREATE A NEW OBJECT AND FILL ITPerson person = new Person();person.setName( "Luke" );person.setSurname( "Skywalker" );person.setCity( new City( "Rome", "Italy") ); // SAVE THE OBJECTdb.save( person );

// QUERY THE OBJECTList<Person> result = database.query( new OSQLSynchQuery("select from person where city.name = 'Rome'"));

// PRINT THE RESULT SETfor( Person p : result ){ System.out.println("Person: " + p.getName() + “ “ + p.getSurname() );}

db.close();

Automatic binding from

POJO to record

Query returns directly List of POJO. Queries use the cache before to load the records from the storage

The POJOs are usable as

usually

For more information visit: http://www.orientechnologies.com

HTTP RESTful API

OrientDBServer

OrientDBServer

Javaapplication

Javaapplication

Fastbinary protocol

select from Profile where project = 'Amiga'

HTTP RESTful protocol (JSON)

{ result : { _rec: 3:4, _ver: 2, name: “Jay”, surname: “Miner” }, { _rec: 4:343, _ver: 0, name: “Tim”, surname: “King” }}

For more information visit: http://www.orientechnologies.com

For more information visit: http://www.orientechnologies.com

Security

“Admin“ RoleMode = Allow all but

“Reader“ RoleMode = Deny all but

Rules:database = Readdatabase.cluster.* = Readdatabase.cluster.metadata = Nonedatabase.class.* = Read

“Publisher“ RoleMode = Deny all but

Rules:Database.Cluster.cars = All

Encrypted password using

SHA-256 algorithm

2 modes: “allow all but” and “deny

all but”

Each user has one or more roles

Default roles are: reader, writer and

admin

For more information visit: http://www.orientechnologies.com

OrientDB Studio

Node #1

Node #3

Node #2

Keys range: 0 .. F

Keys range: G .. R

Keys range: S .. Z

Backup

BackupBack

up

The last node in the Ring is the last

one started

Backup=1 in configuration means

that each node backup data synchronously on

the next one.

Each node is owner of part of keys (Node #1 the range S-Z) and

is responsable to synchronize them to

the disk

Orient Key/Value – Partitions in the Ring

For more information visit: http://www.orientechnologies.com

update band:Coldplay

The client (application or web-browser) connects to

the owner node of the entry to update

save to disk Node #1

Node #3

Node #2

Keys range: 0 .. F

Keys range: G .. R

Backup

BackupBack

up

Keys range: S .. Z

Node #1 is the owner of the updated entry: propagates

changes to the local disk and to backup node synchronously

Orient Key/Value – Update an entry

For more information visit: http://www.orientechnologies.com

save to disk

Node #1

Node #3

Node #2

Keys range: S .. F

Keys range: G .. R

BackupBack

up

Keys range: S .. Z

Backup

The Backup of Node #1 is the Node #2. The

Node #2 becames the owner and assures to write all the entries to

the Disk

Other Nodes envolved change the backup

policies themselves. In this case Node #3

backups on Node #2 and viceversa

Orient Key/Value – Fail Over Management

For more information visit: http://www.orientechnologies.com