Mongodb - drupal dev days
Upcoming SlideShare
Loading in...5
×
 

Mongodb - drupal dev days

on

  • 4,083 views

Introduction to NoSql principles and MongoDB.

Introduction to NoSql principles and MongoDB.

Statistics

Views

Total Views
4,083
Views on SlideShare
4,068
Embed Views
15

Actions

Likes
2
Downloads
42
Comments
0

2 Embeds 15

http://www.slideshare.net 14
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

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
  • Who has heard about nosql?Knows?Opinions?Against SQL? Hell no
  • Nothing NewBut wth is happening since 2000 (1st real end of the world, next is in 2038)?
  • Who cares about what is in that cloud?
  • Up to 40 indexes
  • No Op(yet)
  • Noop yet
  • Noop yet

Mongodb - drupal dev days Mongodb - drupal dev days Presentation Transcript

  • Pierre Joye
    PHP Core Developer
    Microsoft - Open Source Tech Center
    @pierrejoye
  • NoSQL?
    /(no)?SQL/
  • Original diagram by Simon Munro (@simonmunron)
  • Non Sql Databases
    Key-value cache
    Memcached, velocity, apc, wincache
    Key-value store
    Keyspace, Azure table
    eventually-consistentkey-value store
    Voldemort, SimpleDB
    document store
    MongoDB, CouchDB, Riak
    wide columnar store
    BigTable, Hbase, Cassandra, Qbase, Hypertable
    Graph database
    Neo4j
  • A NEW WAY
  • Know your environment
  • DBs
    SQL
    Soap
    Apps
    Apps
    IO
    Key/val
    Cache
    Files
  • Data Cloud
    Apps
    Objects
  • RDBMs
    Apps
    Objects
    NoSql
  • Scalable, High-Performance, Open Source, Document-Oriented Database(and schema-free)
  • and me
    Production Deployments
    More at http://www.mongodb.org/display/DOCS/Production+Deployments
  • Support and Resources
    http://www.mongodb.org
    IRC Freenode #mongodb
    http://groups.google.com/group/mongodb-user
    @mongodb
  • Database
  • Collection
  • Documents
    http://www.flickr.com/photos/critter_lm/199190303/
  • Index
    • Performance
    • Secondary Index
    • Replication/ failover
    • Map Reduce
    • Auto Sharding
    • GIS
    • Cross Platforms and Portable
    • Schema Free
  • Types
    JSON Types
    Null
    Boolean
    Integer
    Long
    Double
    String
    Array
    Object
    BSON Types
    Object id
    Date
    Binary data
    Regular expression
    Code
    Max value
    Min value
    +
  • Demos
  • Setup
  • Representations
  • Connect to MongoDB
    $connection = new Mongo( “localhost:9000" ); 
  • Create a database
    $c = new Mongo( “localhost:9000" ); 
    $db = $c->db2;
  • Create a database
    $c = new Mongo( “localhost:9000" ); 
    $db = $c->db1;
  • Get a Collection
    $conn = new Mongo( "localhost:9000" );
    $db = $conn->db1;
    $collection = $db->user;
    Or
    $collection = $conn->db1->user;
  • Create a Document
    $conn = new Mongo( "localhost:9000" );
    $c = $conn->db1->user;
    $user = array(
    'name' => 'John',
    'age' => 32);
    $c->save($user);
  • Query a Document
    $conn = new Mongo( "localhost:9000" );
    $c = $conn->db1->user;
    $obj = $c->findOne();
    echo "Created on: " . date(DATE_RFC822,
    $obj['_id']->getTimeStamp()) . " ";
  • Update a Document
    <?php
    $conn = new Mongo( "localhost:9000" );
    $c = $conn->db1->user;
    $c->update(
    array('name' => 'John'),
    array('name' => '',
    'age' => 34,
    'city' => 'Munich')
    );
  • Find doc w/o a field
    <?php
    $conn = new Mongo( "localhost:9000" );
    $c = $conn->db1->user;
    $cursor = $c->find(array('city' =>
    array('$exists' => 0)
    )
    );
    echo "Found: " . $cursor->count() . " ";
  • Create Index
    <?php
    $conn = new Mongo( "localhost:9000" );
    $c = $conn->db1->user;
    $c->ensureIndex(array('age' => 1));
    $cursor = $c->find(array('age' =>
    array( '$gt' => 34, '$lt' => 53 )));