MongoDB, a document store that wont let              you down                  Nurul Ferdous     Platform Architect at Tas...
Web 1.0
Web 2.0
MySQL problem
Resolution
NoSQL vs RDBMS          NoSQL                        RDBMS● Schema-free              ●   Relational schema                ...
Who else there?
CAP theorem
MongoDB in CAP
Installing MongoDB serverubuntu way    ●   sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10    ●   deb ht...
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
Understanding MongoDB
PHP and MongoDBInstallation     or `sudo pecl install mongo`To load the extension, add a line in php.ini:`extension=mongo....
Connection
Query
CRUD
SQL to MongoDBCREATE TABLE USERS (a Number, b Number)       $db->users->insert(array("a" => 1, "b" => 1));INSERT INTO USER...
Map Reduce
Map Reduce
Question?● I am  ○ Nurul Ferdous <nurul@ferdo.us>  ○ @ferdous  ○ http://dynamicguy.com/ ● Try it out  ○ http://www.mongodb...
Upcoming SlideShare
Loading in …5
×

MongoDB a document store that won't let you down.

2,245 views

Published on

This talk was given by me at phpXperts seminar 2011 in UIU dhaka.

Published in: Technology
  • Be the first to comment

MongoDB a document store that won't let you down.

  1. 1. MongoDB, a document store that wont let you down Nurul Ferdous Platform Architect at Tasawr Interactive @ferdous, http://dynamicguy.com
  2. 2. Web 1.0
  3. 3. Web 2.0
  4. 4. MySQL problem
  5. 5. Resolution
  6. 6. NoSQL vs RDBMS NoSQL RDBMS● Schema-free ● Relational schema ● Scalable reads● Scalable writes/reads ● Custom high-availability● Auto high-availability ● Flexible queries● Limited queries ● Consistency● Eventual Consistency ● ACID● BASE
  7. 7. Who else there?
  8. 8. CAP theorem
  9. 9. MongoDB in CAP
  10. 10. Installing MongoDB serverubuntu way ● sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 ● deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen ● sudo apt-get update ● sudo apt-get install mongodb-10gen windows (shame on you!) way ● Download - http://mongodb.org/downloads ● Unzip ● Create a data directory ● Run and connect to the server p.s.: 32bit is limited to 2.5gb size limit.
  11. 11. Understanding MongoDB
  12. 12. Understanding MongoDB
  13. 13. Understanding MongoDB
  14. 14. Understanding MongoDB
  15. 15. Understanding MongoDB
  16. 16. Understanding MongoDB
  17. 17. Understanding MongoDB
  18. 18. Understanding MongoDB
  19. 19. Understanding MongoDB
  20. 20. PHP and MongoDBInstallation     or `sudo pecl install mongo`To load the extension, add a line in php.ini:`extension=mongo.so` # of course without quote 
  21. 21. Connection
  22. 22. Query
  23. 23. CRUD
  24. 24. SQL to MongoDBCREATE TABLE USERS (a Number, b Number) $db->users->insert(array("a" => 1, "b" => 1));INSERT INTO USERS VALUES(1,1) $db->users->find(array(), array("a" => 1, "b" => 1));SELECT a,b FROM users $db->users->find(array("age" => 33));SELECT * FROM users WHERE age=33 $db->users->find(array("age" => 33), array("a" => 1,SELECT a,b FROM users WHERE age=33 "b" => 1));SELECT a,b FROM users WHERE age=33 ORDER $db->users->find(array("age" => 33), array("a" => 1,BY name "b" => 1))->sort(array("name" => 1));SELECT * FROM users WHERE age>33 $db->users->find(array("age" => array($gt => 33)));SELECT * FROM users WHERE age<33 $db->users->find(array("age" => array($lt => 33)));SELECT * FROM users WHERE name LIKE "%Joe%" $db->users->find(array("name" => new MongoRegex ("/Joe/")));SELECT * FROM users WHERE name LIKE "Joe%" $db->users->find(array("name" => new MongoRegexSELECT * FROM users WHERE age>33 AND ("/^Joe/")));age<=40 $db->users->find(array("age" => array($gt => 33,SELECT * FROM users ORDER BY name DESC $lte => 40))); $db->users->find()->sort(array("name" => -1));
  25. 25. Map Reduce
  26. 26. Map Reduce
  27. 27. Question?● I am ○ Nurul Ferdous <nurul@ferdo.us> ○ @ferdous ○ http://dynamicguy.com/ ● Try it out ○ http://www.mongodb.org/downloads# ○ http://www.php.net/manual/en/book.mongo.php

×