Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ArangoDB @ RubyConf Argentina

ArangoDB @ RubyConf Argentina

About ArangoDB, Foxx & the tools to access ArangoDB with Ruby. Thanks for having me, RubyConf Argentina :)

Lucas Dohmen

October 25, 2014
Tweet

More Decks by Lucas Dohmen

Other Decks in Programming

Transcript

  1. Lucas Dohmen ‣ From Cologne in Germany ‣ ArangoDB Core

    Team ‣ ArangoDB Foxx & Ruby Stuff ‣ Open Source Developer, Podcaster & CoderDojo Cologne Organizer 3 /\ (~( ) ) /\_/\ ( _-----_(@ @) ( \ / /|/--\|\ V " " " "
  2. Also… ‣ I don’t speak Spanish :( ‣ Will start

    learning it with Duolingo now ‣ Thanks to the interpreters <3 4
  3. Main Features 5 ‣ Open source and free ‣ Multi

    model database ‣ AQL ‣ Extendable through JS ‣ Replication & sharding ‣ High performance & space efficiency ‣ Powerful Admin Interface ‣ Ashikawa & Guacamole ‣ Started in Sep 2011 ‣ Current Version: 2.2
  4. Free and Open Source ‣ Apache 2 License ‣ On

    Github ‣ Do what you want with it ‣ ... and don‘t pay a dime! 6
  5. NoSQL is not “one thing” ‣ Almost all statements about

    ‘all NoSQL databases’ are probably wrong ‣ “NoSQL databases can’t do joins” ‣ “NoSQL databases don’t support transactions” ‣ A lot of different categories ‣ Graph Databases ‣ Data Structure Servers ‣ Aggregate Oriented Databases ‣ Time Series Databases ‣ … 7
  6. Aggregate Oriented Database ‣ Martin Fowler’s Description of Key-Value, Document

    & Column Family ‣ Aggregate Oriented DB: Store an aggregate as one unit ‣ Aggregate: “A cluster of domain objects that can be treated as a single unit” ! ArangoDB ‣ Is an aggregate oriented database ‣ Allow to save documents with logical similarity in collections ‣ Automatic schema recognition for efficient memory handling 8
  7. ‣ Example: Computer Science Bibliography ! ! ! ! !

    ArangoDB ‣ Is a graph database that supports property graphs ‣ Custom traversals and built-in graph algorithms Graph Database 9 Type: inproceeding Title: Finite Size Effects Type: proceeding Title: Neural Modeling Type: person Name: Anthony C. C. Coolen Label: written Label: published Pages: 99-120 Type: person Name: Snchez-Andrs Label: edited
  8. Why is that useful? 11 Entity Value Object Identified by…

    ID Value State is… Mutable Immutable Embed me! Add an edge to me!
  9. AQL ‣ AQL is a relational algebra ‣ It features

    Joins ‣ Simple Example: FOR user IN users FILTER user.active == true RETURN { name: user.name } ‣ Other ways of querying: ‣ Query by Example ‣ Graph Traversals ‣ Foxx for extending your API 12
  10. Why you may want a more expressive query language 13

    Source: http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/ users friends commenter liker many many many many one one posts comments likes
  11. users friends commenter liker many many many many one one

    posts comments likes Why you may want a more expressive query language 14 ‣ Model it as you would in a SQL database ‣ comments gets a commenter_id – then do a join
  12. users friends commenter liker many many many many one one

    posts comments likes Why you may want a more expressive query language 15 ‣ Model it as you would in a document store ‣ posts embed comments as an array
  13. users friends commenter liker many many many many one one

    posts comments likes Why you may want a more expressive query language 16 ‣ Model it as you would in a graph database ‣ users as nodes, friendships as edges
  14. Example for Aggregation ‣ Retrieve cities with the number of

    users: FOR u IN users COLLECT city = u.city INTO g RETURN { "city" : city, "numUsersInCity": LENGTH(g) } 17
  15. Example for Graph Query ‣ Paths: FOR u IN users

    LET userRelations = ( FOR p IN PATHS( users, relations, "OUTBOUND" ) FILTER p._from == u._id RETURN p ) RETURN { "user" : u, "relations" : userRelations } 18
  16. Extendable through JS ‣ JavaScript extends ArangoDB ‣ Multi Collection

    Transactions ‣ Extending the Web API ‣ Aggregate data from multiple queries into a single response ‣ Carry out data-intensive operations ‣ Individual Graph Traversals 19
  17. ‣ Single Page Web Applications ‣ Native Mobile Applications ‣

    ext. Developer APIs ! ‣ ArangoDB has an HTTP API ‣ What if you could talk to the database directly? ‣ It would only need an HTTP API. ‣ What if we could define this API in JavaScript? HTTP APIs 20
  18. ArangoDB Foxx 21 /\ (~( ) ) /\_/\ ( _-----_(@

    @) ( \ / /|/--\|\ V " " " "
  19. Foxx - Simple Example 22 Foxx = require("org/arangodb/foxx"); ! controller

    = new Foxx.Controller(appContext); ! controller.get("/users ", function(req, res) { res.json({ hello: }); }); req.params("name"); /:name
  20. Foxx - More features ‣ Full access to ArangoDB‘s internal

    APIs: ‣ Simple Queries ‣ AQL ‣ Traversals ‣ … ‣ Automatic generation of interactive documentation ‣ Models and Repositories ‣ Central repository of Foxx apps for re-use and inspiration ‣ Background Worker ‣ Authentication Module (BasicAuth & OAuth 2.0) 23
  21. FoxxGenerator ‣ Something I’m working on right now ‣ Build

    your REST API as a state machine ‣ REST as described by Fielding, not DHH ‣ If you are interested in this topic: Talk to me 24
  22. Replication & Sharding ‣ Master/Slave Replication ✓ ‣ Sharding ✓

    ‣ Get the whitepaper on our homepage ‣ Up Next: Auto-Failover 25
  23. High performance & space efficiency ‣ ArangoDB supports automatic schema

    recognition, so it is one of the most space efficient document stores. ‣ Although ArangoDB has a wide range of functions, such as MVCC real ACID, schema recognition, etc., it can compete with popular document stores. 26
  24. gem 'guacamole' ‣ Can’t believe that gem name was still

    free ‣ It’s a Data Mapper ‣ http://guacamolegem.org ! ‣ It uses the ArangoDB Driver Ashikawa::Core 28
  25. 29 class PoniesCollection! include Guacamole::Collection! end! ! class Pony! include

    Guacamole::Model! ! attribute :name, String! attribute :color, String! ! validates :name, presence: true! end! ! pinkie = Pony.new(name: "Pinkie Pie")! PoniesCollection.save pinkie