• Save
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o Facebook
Upcoming SlideShare
Loading in...5
×
 

Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o Facebook

on

  • 2,657 views

La presentazione di Luca Garulli

La presentazione di Luca Garulli
in occasione del Codemotion, Roma 5 marzo 2011 http://www.codemotion.it

Statistics

Views

Total Views
2,657
Views on SlideShare
2,344
Embed Views
313

Actions

Likes
4
Downloads
0
Comments
0

6 Embeds 313

http://www.codemotion.it 177
http://2011.codemotion.it 115
http://lanyrd.com 9
http://codemotion.macaronilab.com 5
http://www.techgig.com 4
http://codemotion.it 3

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o Facebook Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o Facebook Presentation Transcript

  • Perchè potresti avere bisogno di un database NoSQL anche se non sei Google o Facebook Luca Garulli
  • The graph db for the Enterprise & Web www.orientechnologies.com
  • Why do I could need something different than a Relational DBMS ? www.orientechnologies.com
  • (1) RDBMSs have more than 30 years Information Technology is not properly the same of '70 ... www.orientechnologies.com
  • (2) In the Web age applications could have Thousands or Millions of users Are you ready for this? www.orientechnologies.com
  • (3) Time-to-Market measured not anymore in years/man but days/weeks for a demo and months for the final www.orientechnologies.com
  • (4) Applications are more “ social” with much more relationships - tabular data and + interconnected Graphs www.orientechnologies.com
  • (5) Who believe yet to the bullshit that performance problems can be resolved just by scaling with the hardware? www.orientechnologies.com
  • (6) We use new stuff everyday HTTP , REST , Javascript & JSON How can I use them in better way without conversions & mapping? www.orientechnologies.com
  • (7) Modern applications are mostly I/O Bound not CPU bound. Often the DB Is the bottleneck of all www.orientechnologies.com
  • www.orientechnologies.com NoSQL = “Not Only SQL” = make the best choice for your use case
  • Can I trust new DBMSs? www.orientechnologies.com
  • www.orientechnologies.com
  • www.orientechnologies.com Non exhaustive list of NoSQL products: AllegroGraph, Amazon SimpleDB, Amazon Dynamo, Dynomite, BerkleyDB, Google BigTable, Cassandra, CouchDB, DB4O, Hbase, Hipertable, Hive, Jackrabbit, InfiniteGraph, InfoGrid, Memcached, MemcacheDB, Mnesia, M/DB/DT.M, MongoDB, Neo4J, OrientDB , Pig, Project Voldemort, RavenDB, Redis, Riak, Scalaris, Sesame, Sones, Terrastore, Tokyo Cabinet/Tyrant, Yahoo! Pnuts/Sherpa
  • www.orientechnologies.com The “NoSQL container” groups so very-very-very different products, no standard, difficult to choice, difficult to learn them
  • www.orientechnologies.com Can I have a Fast, scalable, flexible storage with transactions , SQL and security easy to use and maintain?
  • www.orientechnologies.com The fastest NoSQL document - graph dbms
  • +12 years of research www.orientechnologies.com
  • +1,5 year of design and development www.orientechnologies.com
  • = best features of newest NoSQL solutions + best features of Relational DBMS + new ideas and concepts www.orientechnologies.com
  • Ø config download, unzip, run! cut & paste the db www.orientechnologies.com
  • No dependencies with 3 rd parties software no conflicts with other software About 1 Mb of run-time libraries www.orientechnologies.com
  • Java ® runs everywhere is available JRE1.5+ robust engine www.orientechnologies.com
  • 150,000 records per second www.orientechnologies.com
  • Schema- less schema is not mandatory, relaxed model , collect heterogeneous documents all together www.orientechnologies.com
  • 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
  • Schema- mixed schema with mandatory and optional fields + constraints the best of schema-less and schema-full modes www.orientechnologies.com
  • ACID Transactions db.begin(); try{ // your code ... db.commit(); } catch( Exception e ) { db.rollback(); } www.orientechnologies.com
  • Complex types native support for collections : ['cool','fast'] maps (key/value): { 'age', 33 } and embedded documents no more additional tables to handle them www.orientechnologies.com
  • Relationships are direct links no Relational JOINS to connect multiple tables Load trees and graphs in few ms ! www.orientechnologies.com
  • Example of a Graph www.orientechnologies.com
  • SQL select * from employee where name like '%Jay%' and status=0 www.orientechnologies.com
  • www.orientechnologies.com A NoSQL product that supports SQL ? Naa... is it a joke?
  • www.orientechnologies.com For the most of the queries everyday a programmer needs SQL is simpler, more readable and compact then Scripting (Map/Reduce)
  • www.orientechnologies.com 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 }; }
  • For Relational skilled Developers (everyone of us?) using OrientDB is easy www.orientechnologies.com
  • 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
  • Language bindings Java as native JRuby , Scala and Javascript ready C , C++ , Ruby , Node.js in progress www.orientechnologies.com
  • Your language is not supported (yet)? Write an adapter using the C, Java or HTTP binding www.orientechnologies.com
  • HTTP RESTful firewall friendly use it from the web browser use it from the ESB (SOA) www.orientechnologies.com
  • Native JSON { '@rid' = '26:10', '@class' = 'Developer', 'name' : 'Luca', 'surname' : 'Garulli', 'company' : '19:76' } www.orientechnologies.com
  • Import/Export uses JSON format online operations (don't stop the database) www.orientechnologies.com
  • MVRB+Tr e e 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
  • www.orientechnologies.com OO Inheritance Definition of Classes of documents Classes can extend others classes Queries are polymorphics Contact name : string surname : string Customer orders : List<Order> Provider products : List<Product>
  • Hooks similar to triggers catch events against records , database and transactions implement custom cascade deletion algorithm enforce constraints www.orientechnologies.com
  • Fetch plans Choose what to fetch on query and document loading Documents not fetched will be lazy-loaded on request Invoice 3:100 | | customer +---------> Customer | 5:233 | city country +---------> City ---------> Country | 11:2 12:3 | orders +--------->* [ OrderItem OrderItem OrderItem ] [ 8:12 8:19 8:23 ] www.orientechnologies.com
  • Security users and roles , encrypted passwords fine grain privileges www.orientechnologies.com
  • 4 storage modes embedded client/server distributed in-memory www.orientechnologies.com
  • Embedded mode really fast runs in the same JVM of the application, less resources, no tcp/ip used www.orientechnologies.com
  • Client/server mode client and server are separated JVMs thousands of clients concurrently remote tcp/ip binary transport www.orientechnologies.com
  • Distributed mode distribute database clusters on multiple servers (in alpha status) www.orientechnologies.com
  • In-memory mode Database lives only in memory No disk is used Destroyed at shutdown www.orientechnologies.com
  • www.orientechnologies.com Java API Document Database Graph Database Object Database
  • Document Database the base of all DB implementations documents have dynamic structure something like a smart Map<String,Object> or a record with dynamic fields www.orientechnologies.com
  • Demo! www.orientechnologies.com
  • SQL Query List<ODocument> result = db.query( new OSQLSynchQuery( &quot;select * from person where city.name = 'Rome'&quot; ) ); for( ODocument d : result ) { System.out.println( &quot;Person: &quot; + d.field( &quot;name&quot; ) + d.field( &quot;surname&quot; ) ); } www.orientechnologies.com
  • Native Query List<ODocument> result = new ONativeSynchQuery<ODocument, OQueryContextNativeSchema<ODocument>>( db, &quot;Profile&quot;, new OQueryContextNativeSchema<ODocument>()) { @Override public boolean filter(OQueryContextNativeSchema<ODocument> iRecord) { return iRecord.field(&quot;city&quot;).field(&quot;name&quot;).eq(&quot;Rome&quot;).and().field(&quot;name&quot;).like(&quot;G%&quot;).go(); }; }.setLimit(20).execute(); www.orientechnologies.com
  • Update a document List<ODocument> result = db.query( new OSQLSynchQuery( &quot;select * from person where city.name = 'Rome'&quot;)); for( ODocument d : result ) { d.field( &quot;local&quot;, true ); d.save(); } // IT'S THE SAME OF: db.command( new OSQLCommand( &quot;update person set local = true where city.name = 'Rome'&quot;)) .execute(); Copyright © 2010 Luca Garulli - www.orientechnologies.com
  • Delete a document List<ODocument> result = db.query( new OSQLSynchQuery( &quot;select * from person where city.name = 'Rome'&quot; ) ); for( ODocument d : result ) { d.delete(); // IT'S THE SAME OF: int deleted = db.command( new OSQLCommand( &quot;delete person where city.name = 'Rome'&quot;)).execute(); Copyright © 2010 Luca Garulli - www.orientechnologies.com
  • from/to JSON // EXPORT JSON System.out.println( document.toJSON() ); // IMPORT JSON document.fromJSON( “{ '@class' = 'Developer', 'name' : 'Luca', 'surname' : 'Garulli' }” ); document.save(); www.orientechnologies.com
  • Use hooks (triggers) public class HookTest extends ORecordHookAbstract { public saveProfile(){ ODatabaseObjectTx database = new ODatabaseObjectTx(&quot;remote:localhost/demo&quot;); database.open(&quot;writer&quot;, &quot;writer&quot;); database.registerHook(this); ... } @Override public void onRecordAfterCreate(ORecord<?> iRecord){ System.out.println(&quot;Record created successfully&quot;); } } www.orientechnologies.com
  • Object Database wrapper on top of Document Database binds POJO from/to the database no OR-Mapping complexity no enhancement, no Java Proxies www.orientechnologies.com
  • POJO mapping Uses the reflection to bind POJO fields at start-up caches reflection meta-data 1-to-1 binding configurable options by @annotations www.orientechnologies.com
  • Demo! www.orientechnologies.com
  • Polymorphics SQL Query List<Person> result = database.query( new OSQLSynchQuery(&quot;select from person where city.name = 'Rome'&quot;)); for( Person p : result ) { if( p instanceof Customer ) System.out.println(&quot;Customer: &quot; + p.getName() + “ “ + p.getSurname() ); } www.orientechnologies.com Queries are polymorphics and subclasses of Person can be part of result set
  • Graph Database wrapper on top of Document Database Few simple concepts: Vertex , Edge , Property and Index www.orientechnologies.com
  • TinkerPop Blueprints http://tinkerpop.com Standard de-facto to interact with GraphDBs implements transactional and indexable property graph model with bidirectional edges www.orientechnologies.com
  • TinkerPop Blueprints Available implementations: OrientDB Neo4J, Sail (RDF storage) Under development: InfiniteGraph, DEX, Redis www.orientechnologies.com
  • GraphDB & Blueprints API OrientGraph graph = new OrientGraph(&quot;local:/tmp/db/graph”); Vertex actor = graph.addVertex(null); actor.setProperty(&quot;name&quot;, &quot;Leonardo&quot;); actor.setProperty(&quot;surname&quot;, &quot;Di Caprio&quot;); Vertex movie = graph.addVertex(null); movie.setProperty(&quot;name&quot;, &quot;Inception&quot;); Edge edge = graph.addEdge(null, actor, movie, &quot;StarredIn&quot;); graph.shutdown(); www.orientechnologies.com
  • TinkerPop scripting language easy to learn and understand Used for operations against graphs www.orientechnologies.com
  • www.orientechnologies.com Graph example graph-example-1.xml
  • Load graph Run the console, open the database and load a graph in xml format marko:~/software/gremlin$ ./gremlin.sh ,,,/ (o o) -----oOOo-(_)-oOOo----- gremlin> $_g := orientdb:open('/tmp/graph/test') ==>orientgraph[/tmp/graph/test] gremlin> g:load('data/graph-example-1.xml') ==>true gremlin> $_g ==>orientgraph[/tmp/graph/test] www.orientechnologies.com
  • Search Displays outgoing edges of vertices with name equals to 'marko', then the name of inbound vertices gremlin> g:key-v('name','marko')/outE ==>e[6:0][5:2-knows->5:1] ==>e[6:1][5:2-knows->5:4] ==>e[6:4][5:2-created->5:0] gremlin> g:key-v('name','marko')/outE/inV/@name ==>vadas ==>josh ==>lop gremlin> g:close() ==>true www.orientechnologies.com
  • API resume object, key/value and graph elements all work on top of Document you can always access to the underlying document changes to the document are reflected to the object, key/value and graph elements and viceversa www.orientechnologies.com
  • 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
  • SQL & relationships select from Account where address .city.country.name = 'Italy' select from Account where addresses contains ( city.country.name = 'Italy') www.orientechnologies.com
  • SQL & trees/graphs select from Profile where friends traverse(0,7) ( sex = 'female' ) (Soon new specific operators for trees and graphs) www.orientechnologies.com
  • 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
  • SQL & conversions select from Shapes where area .toFloat() > 3.14 select from Agenda where birthDate .toDateTime() > '1976-10-26 07:00:00' select from Workflow where completed .toBoolean() = true www.orientechnologies.com
  • SQL & schema-less select from Profile where any() like '%Jay%' select from Stock where all() is not null www.orientechnologies.com
  • 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 Profile where tags in 'cool' select from Graph where edges .size() > 0 www.orientechnologies.com
  • SQL & documents select from Vehicle where @class = 'Car' select from Friend where @version > 100 select from File where @size > 1000000 www.orientechnologies.com
  • High-Availability Cluster of distributed server nodes Synchronous, Asynchronous and Read-Only Replication Load-balancing between client ↔ servers and Servers ↔ Servers www.orientechnologies.com
  • Demo again! OrientDB Studio www.orientechnologies.com
  • Always Free Open Source Apache 2 license free for any purposes, even commercials www.orientechnologies.com
  • Prof €$$ ional $ € rvic €$ by a network of companies through Orient Technologies support, training, consulting, mentoring www.orientechnologies.com
  • www.orientechnologies.com OrientDB for Java developers 8 hours OrientDB Master Development 14 hours OrientDB for SOA 6 hours OrientDB and the power of graphs 6 hours OrientDB for DBA 6 hours OrientPlanet for Web Developers 6 hours
  • Certification Program to be part of the network do courses share revenues for support work as consultant www.orientechnologies.com Contact commercial @orientechnologies.com
  • NuvolaBase.com (beta) www.orientechnologies.com The first Graph Database on the Cloud always available few seconds to setup it use it from app & mobile
  • NuvolaBase.com (beta) www.orientechnologies.com By Alfonso Focareta twitter.com/afocareta & Dino Ciuffetti twitter.com/tuxweb
  • NuvolaBase.com (beta) www.orientechnologies.com Only 350 FREE accounts available for the Get your account for FREE inserting “ CM2011 ” as promotional code! “ CM2011”
  • Luca Garulli Author of OrientDB and Roma <Meta> Framework Open Source projects, Member of JSR#12 (jdo 1.0) and JSR#243 (jdo 2.0) CTO at Asset Data and Orient Technologies Technical Manager at Romulus consortium www.orientechnologies.com www.twitter.com/ lgarulli @Rome, Italy