SlideShare ist ein Scribd-Unternehmen logo
1 von 78
no SQL, no problem
development with mongodb and Sinatra


              Sam Beam
             Onset Corps
A Brief History of
       Relational Databases*
                                      (*as if you need it)


•   “A Relational Model of Data for
    Large Shared Databanks” - Edgar
    F. Codd, 1970 -- IBM

•   “Standard” SQL - Structured
    Query Language

•   ACID (atomicity, consistency,
    isolation, durability)
                                                             photo: osti.gov
The Relational Data Model

• An engine based on “rules” and “facts”
• Consistency/Isolation self-enforced
• ACID
SQL


• History
• Purpose
• “Standards”
• Extensions
SQL


• History
 • 1974 - IBM Research “SEQUEL”
   Ingres, UC Berkley
 • 1979 - 1983 First IBM releases
SQL


• History
 • 1974 - IBM Research “SEQUEL”
   Ingres, UC Berkley
 • 1979 - 1983 First IBM releases
SQL



•   Purpose
    SELECT name FROM emp
    WHERE salary > 55000
      AND dept = ’sales’

    •   Simple, set-based, declarative syntax   brochure: 1980-85 computerhistory.org




                                                               DEC microcomputer 1983 (128kB RAM)
                                                                               computerweekly.com
SQL
                                            IBM Starlink Workstations, 1983
                                                       computerweekly.com




• “Standards”
 •   ANSI SQL-92

 •   no existing RDBMS in full compliance
SQL                                     IBM AS/400
                                                      computerweekly.com




• Extensions
 •   Procedural languages (PL/SQL, T-SQL,pgSQL etc)

 •   Storage type extensions (BLOB, XML, Java)
SQL Extensions
SQL/XML                    SELECT XMLElement
                           (name emp,
Store documents as         XMLForest(last_name || ’,’ ||
CLOB                       first_name AS fullname, salary) )
                           FROM emp;
or mapped to columns

Tools for                  <emp>
 ‣Annotating                 <fullname>Tiger, Scott</fullname>
 ‣Indexing                   <salary>10000</salary>
 ‣Searching (XPath)        </emp>
 ‣Validating (DTD)         <emp>
                             <fullname>Smith, John</fullname>
                             <salary>12000</salary>
XML documents directly     </emp>
SQL Extensions
SQL/XML                    SELECT XMLElement
                           (name emp,
Store documents as         XMLForest(last_name || ’,’ ||
CLOB                       first_name AS fullname, salary) )
                           FROM emp;
or mapped to columns

Tools for                  <emp>
 ‣Annotating                 <fullname>Tiger, Scott</fullname>
 ‣Indexing                   <salary>10000</salary>
 ‣Searching (XPath)        </emp>
 ‣Validating (DTD)         <emp>
                             <fullname>Smith, John</fullname>
                             <salary>12000</salary>
XML documents directly     </emp>
SQL Extensions

Example of specialized, sparse data

Geospatial/Vector
                                       •   Vector Markup Language (VML)
Several choices - all XML              •   Scalable Vector Graphics (SVG)
 •   Geography Markup Language (GML)   •   LandXML
 •   Keyhole Markup Language           •   X3D
 •   G P S eXchange Format (GP X )     •   VRML
SQL Extensions
SELECT TO_NUMBER(EXTRACTVALUE(VALUE(t1), 'trk/number')) as track_number,
       SUBSTR(EXTRACTVALUE(VALUE(t1), 'trk/name'),1,10) as track_name,

       Example of specialized, sparse data
       mdsys.sdo_geometry(CASE WHEN (SELECT COUNT(*)
                                        FROM TABLE(XMLSequence(EXTRACT(VALUE(allSegments),
                                                                         'trk/trkseg',
                                                                         'xmlns="http://www.topografix.com/GPX/1/1"')))) > 1
                                 THEN 3006
                                 ELSE 3002

       Geospatial/Vector    END,
                          8307,
                          NULL,                       • Vector Markup Language (VML)
       Several choices - all XML
         GetElemInfoFromXML(EXTRACT(VALUE(allSegments),'trk/trkseg','xmlns="http://www.topografix.com/GPX/1/1"')),
                                                      • Scalable Vector Graphics (SVG)
        • Geography Markup Language (GML)
         CAST(MULTISET(SELECT case when mod(rownum,3) = 1 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/@lon','xmlns="http://
                                                      • LandXML
        • Keyhole Markup Language when mod(rownum,3) = 2 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/@lat','xmlns="http://
                                                      • X3D
        • G P S eXchange Format (GP X )
                                     when mod(rownum,3) = 0 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/ele/text()','xmlns="h
                                                      • VRML
1/1"'))
                                 end ordinate
                         FROM (select level as rin from dual connect by level < 4) r,
                                 TABLE(XMLSequence(EXTRACT(VALUE(allSegments),'trk/trkseg/trkpt','xmlns="http://www.topogr
                      ) as mdsys.sdo_ordinate_array
             )) as geom
  FROM GPX2 g,
       TABLE(XMLSequence(EXTRACT(g.OBJECT_VALUE,'/gpx/trk','xmlns="http://www.topografix.com/GPX/1/1"'))) t1,
       TABLE(XMLSequence(EXTRACT(VALUE(t1),'trk[number=' || EXTRACTVALUE(VALUE(t1), 'trk/number') || ']','xmlns="http://
1/1"'))) allSegments;
Typical RDBMS Schema
 Issues


 • Conflicts
 • Downtime
 • Deployment
 • Scaling
                image credit: www.magentocommerce.com
Typical RDBMS Schema
           “For purposes of flexibility, the Magento
 Issues    database heavily utilizes an Entity-Attribute-
           Value (EAV) data model. As is often the case,
           the cost of flexibility is complexity -
           Magento is no exception. The process of

 • Conflictsmanipulating data in Magento is often more
           “involved” than that typically experienced using

 • Downtime
           traditional relational tables.”
                 http://www.magentocommerce.com/wiki/

 • Deployment
                                        development/



 • Scaling
                                                   image credit: www.magentocommerce.com
Entity-Attribute-Value
    When you have
  Unknown Unknowns


A “thing” and “properties” engine
(instead of “rules” and “facts”)


 Often found in:
    •e-commerce
    •medical records
    •event logging
    •science                        image: Yale Univ. School of Medicine
                                                  senselab.med.yale.edu
Entity-Attribute-Value


Only alternative:
create table customer(
Cust_ID         number,
Cust_Name        varchar2(xxx),
Cust_Contact     varchar2(xxxx),
field1 varchar2(4000),
field2 varchar2(4000),
...
fieldN varchar2(4000)
)
credit: asktom.oracle.com
Logical Progression
<sarcasm>

         new datatype “xml_universe”
         XML serialized object
         DTD containing all the known attributes of
         "everything"

         Schema:
         CREATE TABLE everything (
             xml_universe NOT NULL
         );

</sarcasm>
Enter the Dragon


    “NoSQL”
Enter the Dragon


            “NoSQL”
NoSQL is a movement promoting a
loosely defined class of non-relational
data stores that break with a long history
of relational databases.
                                   -- Wikipedia
Enter the Dragon


            “NoSQL”
NoSQL is a movement promoting a
loosely defined class of non-relational
data stores that break with a long history
of relational databases.
                                   -- Wikipedia
“NoSQL”
NoSQL is a movement promoting a
loosely defined class of non-relational
data stores that break with a long history
of relational databases.
                                   -- Wikipedia


•   Many techniques
•   Many weapons
•   Many use cases
“NoSQL”
“NoSQL”

    “Not Only SQL”

“Non-Relational Database
  Management System”
“NoSQL”

   neg
    “Not Only SQL”

         ati
              ve
“Non-Relational Database
  Management System”
Structured Storage
   Key-Value Store

   Document Store

  Multivalue Database

      OODBMS
Paradigm Change
Paradigm Change
                CAP Theorem
“One can only have two of Consistency, Availability, and
  tolerance to network Partitions at the same time”
Paradigm Change
                CAP Theorem
“One can only have two of Consistency, Availability, and
  tolerance to network Partitions at the same time”

 If the network is broken, your database won’t work.
Paradigm Change
                CAP Theorem
“One can only have two of Consistency, Availability, and
  tolerance to network Partitions at the same time”

 If the network is broken, your database won’t work.

            The network is going to break.
Paradigm Change
     CAP Theorem
  Consistency




                Availability
Paradigm Change

• Non-relational
• Schema-free
• “Easily” scalable
• OO friendly (no ORM)
• web friendly - REST/JSON API
Paradigm Change
When?

• High-volume, low value
  (social media, web)
• Unknown Unknowns
• Storage of application objects
• Caching, Logging
Paradigm Change
When NOT?

• ACID
• Traditional Waterfall development
• Problems requiring Relational model *

                             * combination?
Paradigm Change
Who’s driving it?
The Candidates
The Candidates
                  Storage Type     License     Implementation

 Cassandra       ColumnFamily *   Apache 2,0        Java

  CouchDB          Document       Apache 2,0       Erlang

   Hbase         ColumnFamily *   Apache 2,0        Java
    Redis          Key/Value         BSD             C

Tokyo Cabinet      Key/Value        LGPL             C
 Voldemort         Key/Value      Apache 2,0        Java

 Memcached         Key/Value         BSD             C

 MongoDB        Document (BSON)   AGPL 3.0          C++
•   Document-oriented
•   Dynamic queries
•   Full dynamic index support
•   Efficient binary large-object storage
•   Built for speed
•   Replication and Auto-failover
Installation

‣ Download source or binary for OS X, Linux, Windows
 http://www.mongodb.org/

‣ Make data directory
 $ mkdir /some/path/mongodb

‣ Run!
 $ bin/mongod --dbpath=/some/path/mongodb
Database Structure


‣Separate DBs
‣Organized into Collections
 top-level key   Document
Collections

‣Group things into logical classes
‣Indexable by one or more keys
‣Schema-free!
Documents


‣Always contains key _id
‣Creating Relationships:
 subdocument, shared key, or DBRef

‣Native storage and transfer : BSON
JSON

            A collection of name/value pairs.
[object, record, struct, dictionary, hash table, keyed list, associative array]


                  An ordered list of values.
                        [array, vector, list, sequence]




                                 http://json.org/
BSON



  BSON is a binary encoded serialization
       of JSON-like documents.




                    http://bsonspec.org/

         http://www.mongodb.org/display/DOCS/BSON
JSON/BSON Example

{
    author     :   "Joe Example",
    created    :   Date(’03-28-2010’),
    title      :   "My latest blog post",
    tags       :   [ "example", "joe", "testing"],
    comments   :   [
                     { author : 'jim', comment : 'I disagree' },
                     { author : 'nancy', comment : 'Good post' }
                   ]
}




                               http://bsonspec.org/

                    http://www.mongodb.org/display/DOCS/BSON
mongo shell
$ mongo
MongoDB shell version: 1.5.0-pre-
url: test
connecting to: test
type "help" for help
> show dbs
admin
shorty
test
> use test
switched to db test
>
mongo shell
$ mongo
MongoDB shell version: 1.5.0-pre-
url: test
connecting to: test
type "help" for help
> show dbs
admin
shorty
test
> use test
switched to db test
> show collections
foo
fs.chunks
fs.files
system.indexes
>
mongo shell
> db.foo.find()
> db.foo.save( { name : 'Fred Flintstone', catchphrase : 'Yabba Dabba doo' } )
> db.foo.find()
{ "_id" : ObjectId("4bcb1dc899d3ae6c0c68035b"), "name" : "Fred Flintstone",
"catchphrase" : "Yabba Dabba doo" }
>
mongo shell
> db.foo.save( { name : 'Fred Flintstone', catchphrase : 'Yabba Dabba doo' } )
> db.foo.save( { name : 'Barney Rubble' } )
> db.foo.find()
{ "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "name" : "Fred Flintstone",
"catchphrase" : "Yabba Dabba doo" }
{ "_id" : ObjectId("4bcb213799d3ae6c0c680362"), "name" : "Barney Rubble" }
>
mongo shell
> for( var i = 1; i < 10; i++ ) db.things.save( { x:'thing'+i, counter:i } );
>
mongo shell
>   for( var i = 1; i < 10; i++ ) db.things.save(   { x:'thing'+i, counter:i } );
>   db.things.find()
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680363"),   "x"   :   "thing1",   "counter"   :   1   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680364"),   "x"   :   "thing2",   "counter"   :   2   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680365"),   "x"   :   "thing3",   "counter"   :   3   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680366"),   "x"   :   "thing4",   "counter"   :   4   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680367"),   "x"   :   "thing5",   "counter"   :   5   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680368"),   "x"   :   "thing6",   "counter"   :   6   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680369"),   "x"   :   "thing7",   "counter"   :   7   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c68036a"),   "x"   :   "thing8",   "counter"   :   8   }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c68036b"),   "x"   :   "thing9",   "counter"   :   9   }
>
mongo shell
> db.things.find( { x : 'thing7' } )
{ "_id" : ObjectId("4bcb22e199d3ae6c0c680369"), "x" : "thing7", "counter" : 7 }
>
mongo shell
>   db.things.find( { counter : { $gt : 5, $lte :   8 } } )
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680368"),   "x" : "thing6", "counter" : 6 }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c680369"),   "x" : "thing7", "counter" : 7 }
{   "_id" : ObjectId("4bcb22e199d3ae6c0c68036a"),   "x" : "thing8", "counter" : 8 }
>
mongo shell
> db.foo.update( { name : 'Fred Flintstone' }, { $set : { wife : 'Wilma' }} )
> db.foo.update( { name : 'Barney Rubble' }, { $set : { wife : 'Betty' }} )
> db.foo.find()
{ "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba
doo", "name" : "Fred Flintstone", "wife" : "Wilma" }
{ "_id" : ObjectId("4bcb213799d3ae6c0c680362"), "name" : "Barney Rubble",
"wife" : "Betty" }
mongo shell
> db.foo.update( { name : 'Fred Flintstone' },
                 { $set : { kids : ['Pebbles'] } } )


> db.foo.findOne( {name : 'Fred Flintstone'} )
{
        "_id" : ObjectId("4bcb213199d3ae6c0c680361"),
        "catchphrase" : "Yabba Dabba doo",
        "kids" : [
                "Pebbles"
        ],
        "name" : "Fred Flintstone",
        "wife" : "Wilma"
}
mongo shell
> db.foo.update( { name : 'Fred Flintstone' },
                 { $push : { kids : 'Bam-Bam' } } )


> db.foo.findOne( {"_id" : ObjectId("4bcb213199d3ae6c0c680361")})
{
        "_id" : ObjectId("4bcb213199d3ae6c0c680361"),
        "catchphrase" : "Yabba Dabba doo",
        "kids" : [
                "Pebbles",
                "Bam-Bam"
        ],
        "name" : "Fred Flintstone",
        "wife" : "Wilma"
}
>
mongo shell
> thing = db.things.findOne( { counter : 3 } )
{
        "_id" : ObjectId("4bcb22e199d3ae6c0c680365"),
        "x" : "thing3",
        "counter" : 3
}
> fred = db.foo.findOne( {name : 'Fred Flintstone'} )
{
        "_id" : ObjectId("4bcb213199d3ae6c0c680361"),
        "catchphrase" : "Yabba Dabba doo",
        "kids" : [
                "Pebbles",
                "Bam-Bam"
        ],
        "name" : "Fred Flintstone",
        "things" : null,
        "wife" : "Wilma"
}
>
mongo shell
>   fred.things = []
[   ]
>   fred.things.push ( new DBRef('things', thing._id) )
>   db.foo.save(fred)
>   fred
{
         "_id" : ObjectId("4bcb213199d3ae6c0c680361"),
         "catchphrase" : "Yabba Dabba doo",
         "kids" : [
                 "Pebbles",
                 "Bam-Bam"
         ],
         "name" : "Fred Flintstone",
         "things" : [
                 {
                         "$ref" : "things",
                         "$id" : ObjectId("4bcb22e199d3ae6c0c680365")
                 }
         ],
         "wife" : "Wilma"
}
mongo shell
> fred.things[0]
{ "$ref" : "things", "$id" : ObjectId("4bcb22e199d3ae6c0c680365") }
> fred.things[0].fetch()
{
        "_id" : ObjectId("4bcb22e199d3ae6c0c680365"),
        "x" : "thing3",
        "counter" : 3
}
>
and   Ruby
and    Ruby


mongo-ruby-driver

   gem install mongo
   gem install mongo_ext
and                     Ruby


Querying
DB = Connection.new('localhost').db('test')

coll = DB['mycollection']

coll.find( { :first_name => 'Fred' } )     # find all Freds

coll.find( { :email => /@gmail.com$/i } )  # Regex

coll.find_one( { :_id => 42 } )            # single record

coll.find( { :age => { '$gte' => 21 } } )   # native conditionals

coll.find( { 'author.first_name' => 'John' } )    # embedded object

coll.find( { '$where' => 'this.age % 7 == 0' } )  # custom conditional
and             Ruby


More Querying
Native conditionals: $in, $nin, $all, $size, $exists, $type

:fields (subset of document keys)
coll.find({:zipcode => '03801'}, {:fields => [:first_name,:last_name]} )


:limit, :skip for pagination
coll.find({:zipcode => '03801'}, {:limit => 100})


sorting
coll.find({:zipcode => '03801'}, {:sort => [:created_at, 'ascending']})


count, distinct and group (does not use Map/Reduce)
and                     Ruby


Inserting and finding
require 'rubygems'
require 'mongo'
include Mongo

DB = Connection.new(ENV['DATABASE_URL'] || 'localhost').db('test')

coll = DB['eyes']

coll.remove

100.times { |i| coll.insert('i' => i, 'token' => rand(1000)) }

coll.find({'token' => { '$gt' => 900 }},
          {:sort => [:token, :descending]}).each { |row| puts row.inspect }
and                     Ruby


Updating in place
coll.update({:token => { '$gt' => 970 }},
            {'$set'=>{:winner => true}},
            {:multi => true});

coll.find(:winner => true).each { |row| puts row.inspect }




{"_id"=>ObjectID('4bcb51a65ea7db36fc000036'), "i"=>53, "token"=>990, "winner"=>true}
{"_id"=>ObjectID('4bcb51a65ea7db36fc000038'), "i"=>75, "token"=>977, "winner"=>true}
and   Ruby


Map/Reduce

Parallel Computing

Delayed Gratification
and            Ruby


Map/Reduce

 Map: chops massive data set into smaller
 problem-specific set


 Reduce: iterates over Map results, combining
 as needed
and            Ruby


Map/Reduce

 Map: chops massive data set into smaller
 problem-specific set


 Reduce: iterates over Map results, combining
 as needed
and                                Ruby


Map/Reduce
   map    = "function() { emit(this.author, {votes: this.votes}); }"
   reduce = "function(key, values) {
     var sum = 0;
     values.forEach(function(doc) {
      sum += doc.votes;
     });
     return {votes: sum};
   };"

   @results = @comments.map_reduce(map, reduce)

   puts @results.find().inspect


  [{"author"="sbeam", "value"=>{"votes"=>21.0}},
   {"author"=>"barney", "value"=>{"votes"=>13.0}}]



             http://kylebanker.com/blog/2009/12/mongodb-map-reduce-basics/
and           Ruby


GridFS

    Store large files

    Transparently chunks

    Incremental delivery (video streaming)
and                       Ruby


GridFS
    @grid = Grid.new(@db)
    # Saving IO data and including the optional filename
    image = File.open("kitty.jpg")
    file_id = @grid.put(image, :filename => "kitty.jpg")

    ....

    @grid = Grid.new(@db)
    # writing file with given _id to HTTP
    if img = @grid.get(Mongo::ObjectID::from_string(params[:file_id]))
        headers 'Content-Type' => img.content_type
        img.read
    end
and           Ruby


Other interesting things
     Capped collections (think memcached)

     Multikeys and Full-text search

     Auto-sharding

     Replica Sets
and        Ruby



Eventual Consistency

can my use case tolerate
• stale reads?
• reading values out of order? 
• not reading my own writes?
and            Ruby


Ruby Adapters

  • MongoRecord
    http://github.com/mongodb/mongo-record
  • MongoMapper
    http://github.com/jnunemaker/mongomapper
  • Candy
    http://github.com/SFEley/candy
and                       Ruby


MongoMapper example
class Post
  include MongoMapper::Document

  key :title, String
  key :body, String

  many :comments, :as => :commentable, :class_name => 'PostComment'
  timestamps!
end

class PostComment
  include MongoMapper::Document

  key :username, String, :default => 'Anonymous'
  key :body, String

  key :commentable_id, ObjectId
  key :commentable_type, String
  belongs_to :commentable, :polymorphic => true

  timestamps!
end
Much more...

• Theory
  http://blog.mongodb.org/
• GUIs
  http://blog.timgourley.com/tagged/nosql
• Support
  http://www.10gen.com/
• sbeam@onsetcorps.net
• http://twitter.com/sbeam
• http://github.com/sbeam/mf1

Weitere ähnliche Inhalte

Was ist angesagt?

Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformMarco Gralike
 
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Marco Gralike
 
Miracle Open World 2011 - XML Index Strategies
Miracle Open World 2011  -  XML Index StrategiesMiracle Open World 2011  -  XML Index Strategies
Miracle Open World 2011 - XML Index StrategiesMarco Gralike
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...Marco Gralike
 
Lightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and CassandraLightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and CassandraRustam Aliyev
 
XML In The Real World - Use Cases For Oracle XMLDB
XML In The Real World - Use Cases For Oracle XMLDBXML In The Real World - Use Cases For Oracle XMLDB
XML In The Real World - Use Cases For Oracle XMLDBMarco Gralike
 
SparkSQL and Dataframe
SparkSQL and DataframeSparkSQL and Dataframe
SparkSQL and DataframeNamgee Lee
 
UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex DatatypesUKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex DatatypesMarco Gralike
 
Spark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSpark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSigmoid
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011Stephen Chin
 
SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템HyeonSeok Choi
 
Updates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesUpdates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesJim Hatcher
 
Object Relational model for SQLIite in android
Object Relational model for SQLIite  in android Object Relational model for SQLIite  in android
Object Relational model for SQLIite in android yugandhar vadlamudi
 

Was ist angesagt? (20)

Clojure Deep Dive
Clojure Deep DiveClojure Deep Dive
Clojure Deep Dive
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will Perform
 
MySQL lecture
MySQL lectureMySQL lecture
MySQL lecture
 
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
 
Miracle Open World 2011 - XML Index Strategies
Miracle Open World 2011  -  XML Index StrategiesMiracle Open World 2011  -  XML Index Strategies
Miracle Open World 2011 - XML Index Strategies
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
 
Lightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and CassandraLightning fast analytics with Spark and Cassandra
Lightning fast analytics with Spark and Cassandra
 
XML In The Real World - Use Cases For Oracle XMLDB
XML In The Real World - Use Cases For Oracle XMLDBXML In The Real World - Use Cases For Oracle XMLDB
XML In The Real World - Use Cases For Oracle XMLDB
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
SparkSQL and Dataframe
SparkSQL and DataframeSparkSQL and Dataframe
SparkSQL and Dataframe
 
UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex DatatypesUKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes
 
Introduction to my_sql
Introduction to my_sqlIntroduction to my_sql
Introduction to my_sql
 
Spark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. JyotiskaSpark Dataframe - Mr. Jyotiska
Spark Dataframe - Mr. Jyotiska
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템
 
Updates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesUpdates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI Indexes
 
Object Relational model for SQLIite in android
Object Relational model for SQLIite  in android Object Relational model for SQLIite  in android
Object Relational model for SQLIite in android
 
3 indexes
3 indexes3 indexes
3 indexes
 

Ähnlich wie no SQL, no problem development with mongodb and Sinatra

Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management Systempsathishcs
 
Dax Declarative Api For Xml
Dax   Declarative Api For XmlDax   Declarative Api For Xml
Dax Declarative Api For XmlLars Trieloff
 
Big data analytics with Spark & Cassandra
Big data analytics with Spark & Cassandra Big data analytics with Spark & Cassandra
Big data analytics with Spark & Cassandra Matthias Niehoff
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparisonshsedghi
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And XmlDavid Truxall
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...Marco Gralike
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Marco Gralike
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologiesBat Programmer
 
Be A Hero: Transforming GoPro Analytics Data Pipeline
Be A Hero: Transforming GoPro Analytics Data PipelineBe A Hero: Transforming GoPro Analytics Data Pipeline
Be A Hero: Transforming GoPro Analytics Data PipelineChester Chen
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cqlzznate
 
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesSyntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesTara Athan
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for PerlGeir Aalberg
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016DataStax
 
SXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup LanguageSXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup Languageelliando dias
 
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScyllaDB
 
SQL-Server Database.pdf
SQL-Server Database.pdfSQL-Server Database.pdf
SQL-Server Database.pdfShehryarSH1
 
Spark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
Spark ETL Techniques - Creating An Optimal Fantasy Baseball RosterSpark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
Spark ETL Techniques - Creating An Optimal Fantasy Baseball RosterDon Drake
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)Serhii Kartashov
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.pptMARasheed3
 

Ähnlich wie no SQL, no problem development with mongodb and Sinatra (20)

Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 
Dax Declarative Api For Xml
Dax   Declarative Api For XmlDax   Declarative Api For Xml
Dax Declarative Api For Xml
 
Big data analytics with Spark & Cassandra
Big data analytics with Spark & Cassandra Big data analytics with Spark & Cassandra
Big data analytics with Spark & Cassandra
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparison
 
Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
DB2 Native XML
DB2 Native XMLDB2 Native XML
DB2 Native XML
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologies
 
Be A Hero: Transforming GoPro Analytics Data Pipeline
Be A Hero: Transforming GoPro Analytics Data PipelineBe A Hero: Transforming GoPro Analytics Data Pipeline
Be A Hero: Transforming GoPro Analytics Data Pipeline
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cql
 
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesSyntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
 
SXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup LanguageSXML: S-expression eXtensible Markup Language
SXML: S-expression eXtensible Markup Language
 
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
 
SQL-Server Database.pdf
SQL-Server Database.pdfSQL-Server Database.pdf
SQL-Server Database.pdf
 
Spark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
Spark ETL Techniques - Creating An Optimal Fantasy Baseball RosterSpark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
Spark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

no SQL, no problem development with mongodb and Sinatra

  • 1. no SQL, no problem development with mongodb and Sinatra Sam Beam Onset Corps
  • 2. A Brief History of Relational Databases* (*as if you need it) • “A Relational Model of Data for Large Shared Databanks” - Edgar F. Codd, 1970 -- IBM • “Standard” SQL - Structured Query Language • ACID (atomicity, consistency, isolation, durability) photo: osti.gov
  • 3. The Relational Data Model • An engine based on “rules” and “facts” • Consistency/Isolation self-enforced • ACID
  • 4. SQL • History • Purpose • “Standards” • Extensions
  • 5. SQL • History • 1974 - IBM Research “SEQUEL” Ingres, UC Berkley • 1979 - 1983 First IBM releases
  • 6. SQL • History • 1974 - IBM Research “SEQUEL” Ingres, UC Berkley • 1979 - 1983 First IBM releases
  • 7. SQL • Purpose SELECT name FROM emp WHERE salary > 55000 AND dept = ’sales’ • Simple, set-based, declarative syntax brochure: 1980-85 computerhistory.org DEC microcomputer 1983 (128kB RAM) computerweekly.com
  • 8. SQL IBM Starlink Workstations, 1983 computerweekly.com • “Standards” • ANSI SQL-92 • no existing RDBMS in full compliance
  • 9. SQL IBM AS/400 computerweekly.com • Extensions • Procedural languages (PL/SQL, T-SQL,pgSQL etc) • Storage type extensions (BLOB, XML, Java)
  • 10. SQL Extensions SQL/XML SELECT XMLElement (name emp, Store documents as XMLForest(last_name || ’,’ || CLOB first_name AS fullname, salary) ) FROM emp; or mapped to columns Tools for <emp> ‣Annotating <fullname>Tiger, Scott</fullname> ‣Indexing <salary>10000</salary> ‣Searching (XPath) </emp> ‣Validating (DTD) <emp> <fullname>Smith, John</fullname> <salary>12000</salary> XML documents directly </emp>
  • 11. SQL Extensions SQL/XML SELECT XMLElement (name emp, Store documents as XMLForest(last_name || ’,’ || CLOB first_name AS fullname, salary) ) FROM emp; or mapped to columns Tools for <emp> ‣Annotating <fullname>Tiger, Scott</fullname> ‣Indexing <salary>10000</salary> ‣Searching (XPath) </emp> ‣Validating (DTD) <emp> <fullname>Smith, John</fullname> <salary>12000</salary> XML documents directly </emp>
  • 12. SQL Extensions Example of specialized, sparse data Geospatial/Vector • Vector Markup Language (VML) Several choices - all XML • Scalable Vector Graphics (SVG) • Geography Markup Language (GML) • LandXML • Keyhole Markup Language • X3D • G P S eXchange Format (GP X ) • VRML
  • 13. SQL Extensions SELECT TO_NUMBER(EXTRACTVALUE(VALUE(t1), 'trk/number')) as track_number, SUBSTR(EXTRACTVALUE(VALUE(t1), 'trk/name'),1,10) as track_name, Example of specialized, sparse data mdsys.sdo_geometry(CASE WHEN (SELECT COUNT(*) FROM TABLE(XMLSequence(EXTRACT(VALUE(allSegments), 'trk/trkseg', 'xmlns="http://www.topografix.com/GPX/1/1"')))) > 1 THEN 3006 ELSE 3002 Geospatial/Vector END, 8307, NULL, • Vector Markup Language (VML) Several choices - all XML GetElemInfoFromXML(EXTRACT(VALUE(allSegments),'trk/trkseg','xmlns="http://www.topografix.com/GPX/1/1"')), • Scalable Vector Graphics (SVG) • Geography Markup Language (GML) CAST(MULTISET(SELECT case when mod(rownum,3) = 1 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/@lon','xmlns="http:// • LandXML • Keyhole Markup Language when mod(rownum,3) = 2 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/@lat','xmlns="http:// • X3D • G P S eXchange Format (GP X ) when mod(rownum,3) = 0 then TO_NUMBER(EXTRACT(VALUE(t), '/trkpt/ele/text()','xmlns="h • VRML 1/1"')) end ordinate FROM (select level as rin from dual connect by level < 4) r, TABLE(XMLSequence(EXTRACT(VALUE(allSegments),'trk/trkseg/trkpt','xmlns="http://www.topogr ) as mdsys.sdo_ordinate_array )) as geom FROM GPX2 g, TABLE(XMLSequence(EXTRACT(g.OBJECT_VALUE,'/gpx/trk','xmlns="http://www.topografix.com/GPX/1/1"'))) t1, TABLE(XMLSequence(EXTRACT(VALUE(t1),'trk[number=' || EXTRACTVALUE(VALUE(t1), 'trk/number') || ']','xmlns="http:// 1/1"'))) allSegments;
  • 14. Typical RDBMS Schema Issues • Conflicts • Downtime • Deployment • Scaling image credit: www.magentocommerce.com
  • 15. Typical RDBMS Schema “For purposes of flexibility, the Magento Issues database heavily utilizes an Entity-Attribute- Value (EAV) data model. As is often the case, the cost of flexibility is complexity - Magento is no exception. The process of • Conflictsmanipulating data in Magento is often more “involved” than that typically experienced using • Downtime traditional relational tables.” http://www.magentocommerce.com/wiki/ • Deployment development/ • Scaling image credit: www.magentocommerce.com
  • 16. Entity-Attribute-Value When you have Unknown Unknowns A “thing” and “properties” engine (instead of “rules” and “facts”) Often found in: •e-commerce •medical records •event logging •science image: Yale Univ. School of Medicine senselab.med.yale.edu
  • 17. Entity-Attribute-Value Only alternative: create table customer( Cust_ID number, Cust_Name varchar2(xxx), Cust_Contact varchar2(xxxx), field1 varchar2(4000), field2 varchar2(4000), ... fieldN varchar2(4000) ) credit: asktom.oracle.com
  • 18. Logical Progression <sarcasm> new datatype “xml_universe” XML serialized object DTD containing all the known attributes of "everything" Schema: CREATE TABLE everything ( xml_universe NOT NULL ); </sarcasm>
  • 19. Enter the Dragon “NoSQL”
  • 20. Enter the Dragon “NoSQL” NoSQL is a movement promoting a loosely defined class of non-relational data stores that break with a long history of relational databases. -- Wikipedia
  • 21. Enter the Dragon “NoSQL” NoSQL is a movement promoting a loosely defined class of non-relational data stores that break with a long history of relational databases. -- Wikipedia
  • 22. “NoSQL” NoSQL is a movement promoting a loosely defined class of non-relational data stores that break with a long history of relational databases. -- Wikipedia • Many techniques • Many weapons • Many use cases
  • 24. “NoSQL” “Not Only SQL” “Non-Relational Database Management System”
  • 25. “NoSQL” neg “Not Only SQL” ati ve “Non-Relational Database Management System”
  • 26. Structured Storage Key-Value Store Document Store Multivalue Database OODBMS
  • 28. Paradigm Change CAP Theorem “One can only have two of Consistency, Availability, and tolerance to network Partitions at the same time”
  • 29. Paradigm Change CAP Theorem “One can only have two of Consistency, Availability, and tolerance to network Partitions at the same time” If the network is broken, your database won’t work.
  • 30. Paradigm Change CAP Theorem “One can only have two of Consistency, Availability, and tolerance to network Partitions at the same time” If the network is broken, your database won’t work. The network is going to break.
  • 31. Paradigm Change CAP Theorem Consistency Availability
  • 32. Paradigm Change • Non-relational • Schema-free • “Easily” scalable • OO friendly (no ORM) • web friendly - REST/JSON API
  • 33. Paradigm Change When? • High-volume, low value (social media, web) • Unknown Unknowns • Storage of application objects • Caching, Logging
  • 34. Paradigm Change When NOT? • ACID • Traditional Waterfall development • Problems requiring Relational model * * combination?
  • 37. The Candidates Storage Type License Implementation Cassandra ColumnFamily * Apache 2,0 Java CouchDB Document Apache 2,0 Erlang Hbase ColumnFamily * Apache 2,0 Java Redis Key/Value BSD C Tokyo Cabinet Key/Value LGPL C Voldemort Key/Value Apache 2,0 Java Memcached Key/Value BSD C MongoDB Document (BSON) AGPL 3.0 C++
  • 38.
  • 39. Document-oriented • Dynamic queries • Full dynamic index support • Efficient binary large-object storage • Built for speed • Replication and Auto-failover
  • 40. Installation ‣ Download source or binary for OS X, Linux, Windows http://www.mongodb.org/ ‣ Make data directory $ mkdir /some/path/mongodb ‣ Run! $ bin/mongod --dbpath=/some/path/mongodb
  • 41. Database Structure ‣Separate DBs ‣Organized into Collections top-level key Document
  • 42. Collections ‣Group things into logical classes ‣Indexable by one or more keys ‣Schema-free!
  • 43. Documents ‣Always contains key _id ‣Creating Relationships: subdocument, shared key, or DBRef ‣Native storage and transfer : BSON
  • 44. JSON A collection of name/value pairs. [object, record, struct, dictionary, hash table, keyed list, associative array] An ordered list of values. [array, vector, list, sequence] http://json.org/
  • 45. BSON BSON is a binary encoded serialization of JSON-like documents. http://bsonspec.org/ http://www.mongodb.org/display/DOCS/BSON
  • 46. JSON/BSON Example { author : "Joe Example", created : Date(’03-28-2010’), title : "My latest blog post", tags : [ "example", "joe", "testing"], comments : [ { author : 'jim', comment : 'I disagree' }, { author : 'nancy', comment : 'Good post' } ] } http://bsonspec.org/ http://www.mongodb.org/display/DOCS/BSON
  • 47. mongo shell $ mongo MongoDB shell version: 1.5.0-pre- url: test connecting to: test type "help" for help > show dbs admin shorty test > use test switched to db test >
  • 48. mongo shell $ mongo MongoDB shell version: 1.5.0-pre- url: test connecting to: test type "help" for help > show dbs admin shorty test > use test switched to db test > show collections foo fs.chunks fs.files system.indexes >
  • 49. mongo shell > db.foo.find() > db.foo.save( { name : 'Fred Flintstone', catchphrase : 'Yabba Dabba doo' } ) > db.foo.find() { "_id" : ObjectId("4bcb1dc899d3ae6c0c68035b"), "name" : "Fred Flintstone", "catchphrase" : "Yabba Dabba doo" } >
  • 50. mongo shell > db.foo.save( { name : 'Fred Flintstone', catchphrase : 'Yabba Dabba doo' } ) > db.foo.save( { name : 'Barney Rubble' } ) > db.foo.find() { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "name" : "Fred Flintstone", "catchphrase" : "Yabba Dabba doo" } { "_id" : ObjectId("4bcb213799d3ae6c0c680362"), "name" : "Barney Rubble" } >
  • 51. mongo shell > for( var i = 1; i < 10; i++ ) db.things.save( { x:'thing'+i, counter:i } ); >
  • 52. mongo shell > for( var i = 1; i < 10; i++ ) db.things.save( { x:'thing'+i, counter:i } ); > db.things.find() { "_id" : ObjectId("4bcb22e199d3ae6c0c680363"), "x" : "thing1", "counter" : 1 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680364"), "x" : "thing2", "counter" : 2 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680365"), "x" : "thing3", "counter" : 3 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680366"), "x" : "thing4", "counter" : 4 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680367"), "x" : "thing5", "counter" : 5 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680368"), "x" : "thing6", "counter" : 6 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680369"), "x" : "thing7", "counter" : 7 } { "_id" : ObjectId("4bcb22e199d3ae6c0c68036a"), "x" : "thing8", "counter" : 8 } { "_id" : ObjectId("4bcb22e199d3ae6c0c68036b"), "x" : "thing9", "counter" : 9 } >
  • 53. mongo shell > db.things.find( { x : 'thing7' } ) { "_id" : ObjectId("4bcb22e199d3ae6c0c680369"), "x" : "thing7", "counter" : 7 } >
  • 54. mongo shell > db.things.find( { counter : { $gt : 5, $lte : 8 } } ) { "_id" : ObjectId("4bcb22e199d3ae6c0c680368"), "x" : "thing6", "counter" : 6 } { "_id" : ObjectId("4bcb22e199d3ae6c0c680369"), "x" : "thing7", "counter" : 7 } { "_id" : ObjectId("4bcb22e199d3ae6c0c68036a"), "x" : "thing8", "counter" : 8 } >
  • 55. mongo shell > db.foo.update( { name : 'Fred Flintstone' }, { $set : { wife : 'Wilma' }} ) > db.foo.update( { name : 'Barney Rubble' }, { $set : { wife : 'Betty' }} ) > db.foo.find() { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba doo", "name" : "Fred Flintstone", "wife" : "Wilma" } { "_id" : ObjectId("4bcb213799d3ae6c0c680362"), "name" : "Barney Rubble", "wife" : "Betty" }
  • 56. mongo shell > db.foo.update( { name : 'Fred Flintstone' }, { $set : { kids : ['Pebbles'] } } ) > db.foo.findOne( {name : 'Fred Flintstone'} ) { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba doo", "kids" : [ "Pebbles" ], "name" : "Fred Flintstone", "wife" : "Wilma" }
  • 57. mongo shell > db.foo.update( { name : 'Fred Flintstone' }, { $push : { kids : 'Bam-Bam' } } ) > db.foo.findOne( {"_id" : ObjectId("4bcb213199d3ae6c0c680361")}) { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba doo", "kids" : [ "Pebbles", "Bam-Bam" ], "name" : "Fred Flintstone", "wife" : "Wilma" } >
  • 58. mongo shell > thing = db.things.findOne( { counter : 3 } ) { "_id" : ObjectId("4bcb22e199d3ae6c0c680365"), "x" : "thing3", "counter" : 3 } > fred = db.foo.findOne( {name : 'Fred Flintstone'} ) { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba doo", "kids" : [ "Pebbles", "Bam-Bam" ], "name" : "Fred Flintstone", "things" : null, "wife" : "Wilma" } >
  • 59. mongo shell > fred.things = [] [ ] > fred.things.push ( new DBRef('things', thing._id) ) > db.foo.save(fred) > fred { "_id" : ObjectId("4bcb213199d3ae6c0c680361"), "catchphrase" : "Yabba Dabba doo", "kids" : [ "Pebbles", "Bam-Bam" ], "name" : "Fred Flintstone", "things" : [ { "$ref" : "things", "$id" : ObjectId("4bcb22e199d3ae6c0c680365") } ], "wife" : "Wilma" }
  • 60. mongo shell > fred.things[0] { "$ref" : "things", "$id" : ObjectId("4bcb22e199d3ae6c0c680365") } > fred.things[0].fetch() { "_id" : ObjectId("4bcb22e199d3ae6c0c680365"), "x" : "thing3", "counter" : 3 } >
  • 61. and Ruby
  • 62. and Ruby mongo-ruby-driver gem install mongo gem install mongo_ext
  • 63. and Ruby Querying DB = Connection.new('localhost').db('test') coll = DB['mycollection'] coll.find( { :first_name => 'Fred' } )     # find all Freds coll.find( { :email => /@gmail.com$/i } )  # Regex coll.find_one( { :_id => 42 } )            # single record coll.find( { :age => { '$gte' => 21 } } )   # native conditionals coll.find( { 'author.first_name' => 'John' } )    # embedded object coll.find( { '$where' => 'this.age % 7 == 0' } )  # custom conditional
  • 64. and Ruby More Querying Native conditionals: $in, $nin, $all, $size, $exists, $type :fields (subset of document keys) coll.find({:zipcode => '03801'}, {:fields => [:first_name,:last_name]} ) :limit, :skip for pagination coll.find({:zipcode => '03801'}, {:limit => 100}) sorting coll.find({:zipcode => '03801'}, {:sort => [:created_at, 'ascending']}) count, distinct and group (does not use Map/Reduce)
  • 65. and Ruby Inserting and finding require 'rubygems' require 'mongo' include Mongo DB = Connection.new(ENV['DATABASE_URL'] || 'localhost').db('test') coll = DB['eyes'] coll.remove 100.times { |i| coll.insert('i' => i, 'token' => rand(1000)) } coll.find({'token' => { '$gt' => 900 }},           {:sort => [:token, :descending]}).each { |row| puts row.inspect }
  • 66. and Ruby Updating in place coll.update({:token => { '$gt' => 970 }}, {'$set'=>{:winner => true}}, {:multi => true}); coll.find(:winner => true).each { |row| puts row.inspect } {"_id"=>ObjectID('4bcb51a65ea7db36fc000036'), "i"=>53, "token"=>990, "winner"=>true} {"_id"=>ObjectID('4bcb51a65ea7db36fc000038'), "i"=>75, "token"=>977, "winner"=>true}
  • 67. and Ruby Map/Reduce Parallel Computing Delayed Gratification
  • 68. and Ruby Map/Reduce Map: chops massive data set into smaller problem-specific set Reduce: iterates over Map results, combining as needed
  • 69. and Ruby Map/Reduce Map: chops massive data set into smaller problem-specific set Reduce: iterates over Map results, combining as needed
  • 70. and Ruby Map/Reduce map    = "function() { emit(this.author, {votes: this.votes}); }" reduce = "function(key, values) {   var sum = 0;   values.forEach(function(doc) {    sum += doc.votes;   });   return {votes: sum}; };" @results = @comments.map_reduce(map, reduce) puts @results.find().inspect [{"author"="sbeam", "value"=>{"votes"=>21.0}}, {"author"=>"barney", "value"=>{"votes"=>13.0}}] http://kylebanker.com/blog/2009/12/mongodb-map-reduce-basics/
  • 71. and Ruby GridFS Store large files Transparently chunks Incremental delivery (video streaming)
  • 72. and Ruby GridFS @grid = Grid.new(@db) # Saving IO data and including the optional filename image = File.open("kitty.jpg") file_id = @grid.put(image, :filename => "kitty.jpg") .... @grid = Grid.new(@db) # writing file with given _id to HTTP if img = @grid.get(Mongo::ObjectID::from_string(params[:file_id]))     headers 'Content-Type' => img.content_type     img.read end
  • 73. and Ruby Other interesting things Capped collections (think memcached) Multikeys and Full-text search Auto-sharding Replica Sets
  • 74. and Ruby Eventual Consistency can my use case tolerate • stale reads? • reading values out of order?  • not reading my own writes?
  • 75. and Ruby Ruby Adapters • MongoRecord http://github.com/mongodb/mongo-record • MongoMapper http://github.com/jnunemaker/mongomapper • Candy http://github.com/SFEley/candy
  • 76. and Ruby MongoMapper example class Post   include MongoMapper::Document   key :title, String   key :body, String   many :comments, :as => :commentable, :class_name => 'PostComment'   timestamps! end class PostComment   include MongoMapper::Document   key :username, String, :default => 'Anonymous'   key :body, String   key :commentable_id, ObjectId   key :commentable_type, String   belongs_to :commentable, :polymorphic => true   timestamps! end
  • 77. Much more... • Theory http://blog.mongodb.org/ • GUIs http://blog.timgourley.com/tagged/nosql • Support http://www.10gen.com/

Hinweis der Redaktion

  1. E.F. Codd asserted that, mathematically, no commercial database conformed to his true Relational modelPredicates, Predicate variables, relations, tuples, superkeys, finite projectionsAtomicity Consistency Isolation Durability
  2. IBM&amp;#x2019;s first SQL release: System R paper: 1974
  3. Bring attention to EAV box!
  4. originated with the concept of &quot;association lists&quot; AKA key/value pairs A &amp;#x201C;simple&amp;#x201D; way to attach arbitrary attributes and values to records in a normalized RDMBS
  5. &quot;Physical schema&quot; (actual storage structure) is radically different from the &quot;logical schema&quot; &amp;#x2013; the way users and applications see it. PIVOTING: Converting logical schema to/from physical schema Note: full scan, no type control
  6. Inefficiency - non-optimal JOINs Leaky abstraction
  7. memcached - K/V store Lotus Notes - multivalue Zope Object Database - OODBMS marketibility?
  8. combination - facebook &amp;#x201C;Hive&amp;#x201D; based on Hadoop with &amp;#x201C;QL&amp;#x201D;
  9. mostly Hadoop, true
  10. A column family is a container for columns, analogous to the table in a relational system. CouchDB - REST interface, JSON response Redis - in-memory, journaled changes to data stored to disk Tokyo Cabinet - update of GDBM Hbase - the Hadoop Database, modeled on Google BigTable
  11. (JavaScript Object Notation) is a lightweight data-interchange format.It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.
  12. assigning specific documents to &amp;#x201C;thing&amp;#x201D; and &amp;#x201C;fred&amp;#x201D;
  13. Using DBRef to create a reference between collections
  14. Showing that the $ref object in fred is tied to the actual record in things collection
  15. find always returns a MongoDB::Cursor that is iterable / The query doesn&amp;#x2019;t get run until you actually attempt to retrieve data from a cursor. / Cursors have a to_a method. find_one returns a single object where uses any valid JS expression
  16. $in = array contains, $all = array equivalent, $size = count fields $exists = bool, $type = string/int
  17. complete ruby program
  18. collection.update(selector, document, options = {}) Upserts - :upsert -&gt; true
  19. patented[1] software framework introduced by Google to support distributed computing on large data sets on clusters of computers.[2]
  20. CouchDB - lacks native conditionals, but uses Javascript anyway is SQL that much better?
  21. specify the map and reduce functions in JavaScript, as strings reduce receives array of values for each element emitted by map
  22. chunks = 256k, auto-sharded GridFilesystem - emulates a filesystem - write, open, close, delete, etc GridFS saves whatever metadata - GridFS is a specification for mapping chunks-&gt;files
  23. CC: FIFO - Logging, caches, auto-archiving MK: auto-index on any array values FTS : split text into array, use MK - no native stemming, bulk index (yet) AS : beta. Uses router (godfather), config servers (consiglere), mongod instances (map/reduce recommended) RP: master/slave - to be replaced by Replica Sets in 1.6 - Eventual Consistency
  24. Amazon popularized the concept of &amp;#x201C;Eventual Consistency&amp;#x201D;.&amp;#xA0; Their definition is:&amp;#xA0;the storage system guarantees that if no new updates are made to the object, eventually all accesses will return the last updated value.
  25. MongoRecord = 10gen&amp;#x2019;s Original OM, ActiveRecord-ish, works w/ Rails mongomapper - datamapper-ish v0.7 - in production Candy - Candy&apos;s goal is to provide the simplest possible object persistence for the MongoDB database. By &quot;simple&quot; we mean &quot;nearly invisible.&quot; Candy doesn&apos;t try to mirror ActiveRecord or DataMapper. (alpha 0.2)
  26. taken directly from tests