Your SlideShare is downloading. ×
  • Like
  • Save
Hotcode 2013: Javascript in a database (Part 1)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Hotcode 2013: Javascript in a database (Part 1)

  • 1,309 views
Published

In this hotcode 2013 talk Lucas and Frank gave an overview over NoSQL and explained why Javascript

In this hotcode 2013 talk Lucas and Frank gave an overview over NoSQL and explained why Javascript

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,309
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. JavaScript in the DatabaseFrank Celler & Lucas Dohmenwww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 2. The NoSQL Movementwww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 3. CAPwww.arangodb.org (c) f.celler@triagens.deACIDBASESamstag, 1. Juni 13
  • 4. www.arangodb.org (c) f.celler@triagens.denosql.eventbrite.comdistributed structureddata storageSamstag, 1. Juni 13
  • 5. Your EntitiesA Person has aName, first and lastone or more addresses, emails,telephonea list of hobbies, skills, tagswww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 6. Relational Worldwww.arangodb.org (c) f.celler@triagens.dePersonPersonPersonAddressAddressAddressHobbyHobbyHobbyemailemailemailn-to-mn-to-mn-to-mn-to-mn-to-mn-to-mn-to-mn-to-mn-to-mSamstag, 1. Juni 13
  • 7. Use AggregatesDo not Normalizewww.arangodb.org (c) f.celler@triagens.de{ name: { first: „Frank“, last: „Celler“ },address: { home: { street: „...“, city: „...“ } },email: { work: „frank@celler.de“ },hobbies: [ „C++“, „MRuby“, „JavaScript“ ] }Samstag, 1. Juni 13
  • 8. Document Databasesdocuments can beas simple as key/value mapsor as complex as lists containing embeddedsub-documentsor anything in betweenrepresentated in JSONSchema-lesswww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 9. www.arangodb.org (c) f.celler@triagens.de 9Samstag, 1. Juni 13
  • 10. www.arangodb.org (c) f.celler@triagens.de 10Analytic Processing DBsTransaction Processing DBsManaging the evolving state of an IT systemMap/ReduceGraphsExtensibilityKey/ValueColumn-StoresComplexQueriesStructuredDataMassivelyDistributedDocumentsSamstag, 1. Juni 13
  • 11. Property Graphswww.arangodb.org (c) f.celler@triagens.deType: inproceedingTitle: Finite Size EffectsType: proceedingTitle: Neural ModelingType: personName: Anthony C. C. CoolenLabel: writtenLabel: publishedPages: 99-120Type: personName: Snchez-AndrsLabel: editedJust DocumentsSamstag, 1. Juni 13
  • 12. Multi-Model Databaseswww.arangodb.org (c) f.celler@triagens.devertices and edges are documentsquery them using geo-index, full-text,SQL-like queriesrelations are expressed as graphstraverse them using graph algorithmsSamstag, 1. Juni 13
  • 13. ArangoDB.explain()www.arangodb.org (c) f.celler@triagens.de{"type": "NoSQL database","model": [ "document", "graph", "key-value" ],"openSource": true,"license“: "apache","version": 1.3,"builtWith": [ "C", "C++", "js" ],"Javascript": [ "client side", "server side" ],"uses": [ "V8" ]}Samstag, 1. Juni 13
  • 14. Why Use JavaScript?www.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 15. JavaScript Everywherein the BrowserApplication-Layer (Node.JS)Databasewww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 16. Why is Node not enough?www.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 17. JavaScript in a DatabaseMVC in the Browser and/or NODE.JSScript-Language in the DB fortransactions as functionsgraph traversalno-backend, just APIwww.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 18. db._create("accounts");db.accounts.save({ _key: "john", amount: 423 });db.accounts.save({ _key: "fred", amount: 197 });db._executeTransaction({collections: {write: "accounts"},params: {user1: "fred",user2: "john",amount: 10},action: function (params) {var db = require("internal").db;var account1 = db.accounts.document(params[user1]);var account2 = db.accounts.document(params[user2]);var amount = params[amount];if (account1.amount < amount) {throw "account of user " + user1 + " does not have enough money!";}db.accounts.update(account1, { amount : account1.amount - amount });db.accounts.update(account2, { amount : account2.amount + amount });/* will commit the transaction and return the value true */return true;}});www.arangodb.org (c) f.celler@triagens.deTransactionsSamstag, 1. Juni 13
  • 19. db._executeTransaction({collections: {write: "accounts"},params: {user1: "fred",user2: "john",amount: 10},action: function (params) {var db = require("internal").db;var account1 = db.accounts.document(params[user1]);var account2 = db.accounts.document(params[user2]);var amount = params[amount];if (account1.amount < amount) {throw "account of user " + user1 + " does not have enough money!";}db.accounts.update(account1, { amount : account1.amount - amount });db.accounts.update(account2, { amount : account2.amount + amount });www.arangodb.org (c) f.celler@triagens.deTransactionsSamstag, 1. Juni 13
  • 20. function traverse (graph, start, depth, maxlen) {var config = {datasource: traversal.collectionDatasourceFactory(graph._edges),strategy: Traverser.BREADTH_FIRST,expander: traversal.anyExpander,filter: traversal.maxDepthFilter,maxDepth: depth,uniqueness: { edges: Traverser.UNIQUE_GLOBAL, vertices: Traverser.UNIQUE_NONE },visitor: coauthorVisitor(maxlen)};var traverser = new Traverser(config);var result = { positions: {}, vertices: [], links: [], minYear: 0, maxYear: 0 };var first = graph._vertices.firstExample({ name: start });if (first !== null) {traverser.traverse(result, first);}return {start: start,depth: depth,minYear: result.minYear,maxYear: result.maxYear,vertices: result.vertices,links: result.links };}www.arangodb.org (c) f.celler@triagens.deGraph TraversalSamstag, 1. Juni 13
  • 21. function traverse (graph, start, depth, maxlen) {var config = {datasource: traversal.collectionDatasourceFactory(graph._edges),strategy: Traverser.BREADTH_FIRST,expander: traversal.anyExpander,filter: traversal.maxDepthFilter,maxDepth: depth,uniqueness: { edges: Traverser.UNIQUE_GLOBAL,vertices: Traverser.UNIQUE_NONE },visitor: coauthorVisitor(maxlen)};www.arangodb.org (c) f.celler@triagens.deGraph TraversalSamstag, 1. Juni 13
  • 22. No Back-End?www.arangodb.org (c) f.celler@triagens.deSamstag, 1. Juni 13
  • 23. To Be Continued ... NowFork me on githubGoogle Group: ArangoDBTwitter: @fceller & @arangodbwww.arangodb.orgwww.arangodb.org (c) f.celler@triagens.deStay in Touch:Samstag, 1. Juni 13