3. Who am I?
Hi, I am Troy. I have fun as a full stack programmer. I
develop using ASP.NET MVC or Node.js on the backend
and the web or mobile up front.
!
I can be reached at: rockncoder@gmail.com
8. MongoDB 9 to 5
• Two day intensive training
• July 19th & 26th
• 9 AM - 5 PM
• ITT Technical Institute,Torrance, CA
9. Agenda
• Introduction to
MongoDB
• The MongoDB Shell
• Using MongoDB
• Advanced MongoDB
• MongoDB Tools
• To MongoDB or not to
MongoDB
• Summary
• Questions
11. What is MongoDB?
• Cross-platform document database
• Developed by MongoDB Inc in 2007
• Production ready since March 2010
• Free and open-source
• The most popular NoSQL database
12. Top DB-Engines
• Oracle
• MySQL
• MS SQL Server
• PostgreSQL
• MongoDB
!
• DB2
• MS Access
• SQLite
• Cassandra
• Sybase ASE
13. Who Uses It?
• Craigslist
• eBay
• Foursquare
• SourceForge
• Viacom
• Expedia
• Parse
• LinkedIn
• Medtronic
• eHarmony
• CERN
• and more
15. What is a Document?
• An ordered set of keys and values
• like JavaScript objects
• no duplicate keys allowed
• type and case sensitive
• field order is not important or guaranteed
16. What’s Wrong with
SQL?
• SQL was created by Edgar F. Codd in 1969
• OracleV2 introduced in 1979
• MS SQL Server introduced in 1989
• Today most languages are object-oriented
• SQL is column and row oriented
17. A Contact Manager
• first name
• last name
• home address
• work address
• mobile phone
• home phone
18. In SQL
• Person table
• Address table
• Phone number table
• Joins necessary to retrieve
19. In MongoDB
• One document holds it all
• Including the arrays
• No joins necessary
21. Installation
• The current version is 2.6.1
• Downloads available for Windows, Linux,
Mac OSX, and Solaris
• 64-bit for all systems, 32-bit for Windows &
Linux
• 32-bit is not recommends except for
learning
22. Windows
• Download MongoDB
• Unzip the file
• Move it, if necessary
• Set up the MongoDB environment
• Start MongoDB
• Connect to MongoDB
23. Mac OS X
• The best way is to use Homebrew
• brew update
• brew install mongo
38. Profiler
• Collects data about MongoDB database
commands
• Enabled per-database or per-instance basis
• Profile level is configurable (0, 1, or 2)
39. Stats
• db.stats()
• Statistics that reflect the use of a single DB
• Identifies:
• the current database
• the number of indexes
• the file size
40. Replication
• Keeps identical copies of data on multiple
servers
• Set up by creating a replica set
• A replica set is a group of servers with one
primary
• If primary crash, secondaries elect a new
one
41. Backup
• mongodump - command line tool
• You must have backup and read privileges
• No arguments connects to the local DB
• —db, limits the database
• —collection, limits the collections
• —oplog, makes snapshots possible
42. Restore
• mongorestore --port <port number>
<path to the backup>
• Can restore to a running instance or to the
files
• —oplogReplay,
• —filter, allows restore only if filter is true
43. Sharding
• Process of splitting data up across machines
• Manual sharding can be with most database
• MongoDB has autosharding
• Nonetheless it is difficult to configure
47. Not to MongoDB
• Transactions are needed
• You are happy with what you have
• You have have
48. To MongoDB
• You do a lot of non-transactional writes
• You need to grow wide
• You work with location based data
• You need high availability
49. MongoDB as a Service
• MongoHQ
• MongoLab
• MongoDirector
• ObjectRocket, (Rackspace)
50. Summary
• MongoDB is an open-source document
database
• It features JSON-style documents with
dynamic schemas
• In order to gain performance, it sacrifices
reliability