MongoDB for development managers
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


MongoDB for development managers

Uploaded on

These slides provide a useful overview of mongodb based software development -- particularly from a Project management (development) perspective. It does NOT provide information from a developer's......

These slides provide a useful overview of mongodb based software development -- particularly from a Project management (development) perspective. It does NOT provide information from a developer's or architect's perspective.

More 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


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • Software Development managers are often required to manage projects that involve technologies which they are not familiar with. This may happen when a project involves multiple technologies and it is not practical to assign a manager who is expert in all the technologies. Depending on time constraints, it may also be difficult for the manager to browse the internet for available material and go through it all.These slides (“MongoDB for Development managers”) provide an overview of MongoDB based development – focusing on those topics that a development manager typically finds useful. The slides are not meant for MongoDB developers or software architects designing a MongoDB based application. Topics included in this set of slides are: Overview of MongoDB – what it is and why to use it Major features of MongoDB, its requirements, product release information Availability of skills, training on the MongoDB platform Development process for MongoDB Sample code for common usecase implementations (Create, Read, Update, Delete of records from the MongoDB database) References for additional information
  • MongoDB is a DBMS used for maintaining database in an application. It is not a RDBMS (relational DBMS) and does not support SQL as an interface for accessing the database. It is a “Document oriented database” management system which does not have a separate, predefined schema that every data object (record) needs to conform to. A MongoDB dataset can have records that differ in terms of the fields and/or the corresponding data types. An XML document is a common example of a Document oriented database record. MongoDB documents are represented using the JSON (JavaScript Object Notation) format – while XML documents are represented using the XML specification.RDBMS stores data as “Rows” in “Tables”. MongoDB stores data as “Documents” in “Collections”. So an example MongoDB collection would be an “employees” collection with one document for each employee in the database collection (see next slide)
  • The example shown in this slide is a text representation of an employee document. As can be seen, the “currentYearEarnings” field in the document is an array of numeric values. This is different from Relational databases which do not support array fields (or multivalued fields).Also, the “phoneNumbers” field in the document is an array of nested data structures. Again, this is different from relational databases which support only single valued “flat” fields.A MongoDB document is stored using a “binary JSON” format (“BSON” format) for better storage and scan efficiency.
  • Create/Read/Update/Delete:Like other databases, MongoDB also supports the CRUD operations on records in the dataset (documents in a collection)Document oriented:Each database is organized (from application development perspective) as a set of Collections – each collection with a number of Documents. Each document corresponds to a record and it contains a number of data fields of different data types. In addition to common data types like strings, numbers, boolean, etc., MongoDB also supports multivalued fields (arrays). Additionally, it also supports nested data fields where a data field contains sub-fields which in turn may contain other sub-fields – up to any depth. Aggregation framework:MongoDB provides an Aggregation framework as part of its API. This framework can be used to perform “pipeline processing” on the input dataset. The processing pipeline can be specified as a series of one/more (usually more than one) processes – first process taking specified dataset as input, processing it and providing input for the second process…. And, so on. The last process in the pipeline provides overall output of the pipeline. The processes in the pipleline may include one/more of following: Matching – to select a subset of documents based on the match criteria specified in terms of field values. Similar to “WHERE clause” in SQL Projection – to return specified fields and/or values derived from them. Similar to SELECT in SQL Sort – to return fields in a specified sort order Grouping – to return a document that groups one/more documents in the input dataset based on the grouping criteria specified. Similar to “GROUP BY” clause in SQL Unwind – returns multiple documents corresponding to a single document in the input dataset which contains an array-valued field. Example: consider a single document corresponding to a department in an organization. Say, this document has an array-valued field corresponding to monthly sales for current year. An unwind on this document with the monthly sales as the unwind key, will return multiple documents – one document for each value in the array-valued field of the original document
  • MongoDB data can be accessed through the “mongo” shell tool that supports javascript syntaxMongoDB data can also be accessed using APIs in a number of programming languages (C, PHP, Perl, Python, Java, C#, etc.)MongoDB supports load balancing through the “Sharding” feature – distributing data across multiple nodes based specified one/more key fields in the collection.MongoDB supports enhanced fault tolerance using the “Replica sets” feature. This allows user to set up replicas of a dataset – in the event of a primary node failure, another node is elected as the new primary and all subsequent write operations directed to the new primary. Every write operation is automatically replicated across the non-primary nodes by MongoDB.
  • Purpose of this slide is to provide information on technical requirements, licensing requirements and support available, when using this software.
  • The purpose of this slide is to let development managers know out prospects for future upgrades and bug fixes, based on release history.
  • Purpose of slide: provide a sense of the development complexity in using this software
  • Is this slide required at all (for MongoDB)? Runtime behavior of a tool is more useful to a developer and an architect. And that information is far more exhaustive to fit into this set of slides.


  • 1. MongoDB for Development managers -- A. N. Ranpise
  • 2. What is MongoDB• MongoDB is a software tool for creating Document oriented databases (one kind of non-relational databases)• Relational DBs (as against non-relational DBs) – organize data in the form of relational tables – Each table has a “schema” known to the DBMS – And, DBMS enforces the schema on each row (record) of the table – Support SQL for data definition (DDL) and manipulation (DML)• Document oriented DBs – do not support schema definition (is this true only of MongoDB?) – Thus, no question of enforcing fixed schema on each row (record) – No support for SQL based data definition/manipulation• Different terminology used by MongoDB – “Document” instead of “Record” (or “Row”) – “Collection” instead of “Table” Copyright by A.N.Ranpise. ( 2013. All Rights 2 reserved.
  • 3. What is MongoDB (continued)• a Document oriented DBMS• Data objects (Records) organized as binary JSON Documents in a Collection• EXAMPLE below shows a text JSON document (record) corresponding to an employee { "firstName": "John", "lastName": “Sha“, "age": 45, "address": { "streetAddress": “First Street", "city": “Boston", "state": “MA", "postalCode": 12345 }, "currentYearEarnings": [80150, 80200, 80200, 80150, 80300, 80300, 80300, 84500, 84500, 84500, 84500, 84500] "phoneNumbers": [ { "type": "home", "number": “508-555-1234" }, { "type": “cell", "number": “508-555-5678" } ] } Copyright by A.N.Ranpise. ( 2013. All Rights 3 reserved.
  • 4. Why MongoDB• Web scale databases with hundreds of millions of users require scalability far greater than what is practical with RDBMS• E.g. Twitter’s 7TB per day data access requirement – 70 MB/sec disk drives would need more than one day just to execute the data access – And the requirements will keep growing• Continued… Copyright by A.N.Ranpise. ( 2013. All Rights 4 reserved.
  • 5. Why MongoDB (continued…)– The required scale needs to be supported through clustered DB (with many nodes working in parallel)– requires • Easy to manage nodes that dynamically join/leave the cluster • Flexible data structures that can changed with minimal processing overheads for updating indexes, etc • Avoiding runtime joins which need lot of processing– These requirements are being addressed through new categories of non-relational DBMSes– MongoDB belongs to the Document oriented DBMSes – one subcategory of the non-relational DBMS Copyright by A.N.Ranpise. ( 2013. All Rights 5 reserved.
  • 6. Role of MongoDB in developing applications• Used as a DBMS that supports “Document oriented databases” – Each record in the database is called a “Document” and the entire set of records called a “Collection”. – Loosely put, • Document maps to a RDBMS Row, and • Collection maps to a RDBMS Table• Provides APIs in various languages for accessing data (Java, Python, etc.) – need corresponding driver• Also provides a Javascript based query tool (“mongo”) to support CRUD (Create/Read/Update/Delete) access• Provides administrative tools for managing the application databases (mongoimport, etc.) Copyright by A.N.Ranpise. ( 2013. All Rights 6 reserved.
  • 7. Other tools providing comparable benefits• Several other “Document oriented databases” available (see• Examples: CouchDB, Cassandra, MUMPS, XML Copyright by A.N.Ranpise. ( 2013. All Rights 7 reserved.
  • 8. MongoDB – Major Features– Document oriented DBMS– CRUD (Create/Read/Update/Delete) like any DBMS– No schema to be defined for a collection.– Indexing to improve access performance like any DBMS– Support for multi-valued fields as “Array” fields • RDBMS supports only single-valued fields (columns)– Support for nested data-structured fields (called “sub-documents” in MongoDB) • Example: field ‘address’ in a document may be a sub-document consisting of 3 fields: ’streetAddress’, ‘city’ and ‘state’– Aggregation framework for “pipeline processing” of documents (e.g. select, project, group, sort). See Note 2 in Notes below. Copyright by A.N.Ranpise. ( 2013. All Rights 8 reserved.
  • 9. Major features (continued)• Support for many programming languages through “drivers” – each providing API for accessing data – Java, python, .NET, C, PHP, Perl, etc.• Mongo shell – for javascript based access (supports CRUD, Aggregation, etc.)• “Replica sets” for improved availability of data – mongodb maintains replicas of data on all nodes in a replica set (each write operation is replicated)• “Sharding” for improved load balancing across a cluster – Documents distributed across cluster of nodes depending on values of specified fields Copyright by A.N.Ranpise. ( 2013. All Rights 9 reserved.
  • 10. Requirements• Any of the supported OS platforms: – Includes Unix, Windows, Solaris, OS X, – See• Licensing – Free downloadable binaries for supported platforms – along with the “drivers” for supported programming languages – Enhancements to mongodb server need to be released to the mongodb community – for details• Support available – 24x7 support on related forums – Also available, Commercial subscription – Copyright by A.N.Ranpise. ( 2013. All Rights 10 reserved.
  • 11. Vendor & product releases information – 10gen ( – company behind MongoDB – Over 500 commercial customers • Including Cisco, Disney, EA, eBay, Ericsson, Forbes, Intuit, LexisNe xis, SAP and Telefonica – for information on recently (December 2012) available downloads • Production release 2.2.2 (27th Nov. 2012) • Production release 2.0.8 (19th Nov. 2012) Copyright by A.N.Ranpise. ( 2013. All Rights 11 reserved.
  • 12. Skills, training availability• Relatively new tool (like other Document oriented databases and NoSQL databases) – So, developers with MongoDB skills not as readily available as those with SQL development skills – Easier option is to train available developers with SQL experience• Training available – Good Online course at (from 10gen) – Good documentation available – support readily available on user forums• Learning effort – Not difficult to begin with CRUD functions, Aggregation framework, Indexing -- features that are commonly used in development of applications using MongoDB as the DBMS) – I would put it in same league as learning SQL based development Copyright by A.N.Ranpise. ( 2013. All Rights 12 reserved.
  • 13. Development complexityLot of points listed below are subjective. Might be better to only provide facts and let reader assess complexity level – as subjective info may not be applicable in all situations. – Download, Installation – very simple. Just download and extract from tar/zip files – Setup, configuration – none required – Administration – easy startup, shutdown steps – Other administration – monitoring, control, events, tuning, etc. (TBD) – Interactive query program “mongo” provided to perform queries, updates, Aggregation tasks (grouping, counting, summing, sorting, filtering, etc.), …. – Drivers for various programming languages (Java, Python, PHP, C#, Perl, Ruby, ‘C’, etc.) – Driver API complexity – reasonably easy to use (may vary with language used) – Application build procedure • different for each programming language. • No steps required to build Python apps if being run on Python VM (is this generally true? What situations does one use Python compiler in?) • Java apps need to be compiled using java compiler or built using ‘ant’ scripts – Testing database read/write functionality of applications using MongoDB • Easy to test using mongo shell. Copyright by A.N.Ranpise. ( 2013. All Rights 13 reserved.
  • 14. Runtime behavior• Notes: – Any notable effects on performance, scalability, security, manageability, etc.??? – From project management perspective (as against Architecture or Design) only “notable” characteristics need to be mentioned here Copyright by A.N.Ranpise. ( 2013. All Rights 14 reserved.
  • 15. Build process apps using MongoDB – The build process is as required by • the programming language used for the app AND • the planned runtime environment – Using MongoDB does not require any different build steps (only needs including the corresponding MongoDB driver) – MongoDB used through the drivers for corresponding programming language • E.g. pymongo driver for Python apps Copyright by A.N.Ranpise. ( 2013. All Rights 15 reserved.
  • 16. Sample code snippets (Python) Adding a document to a collection in MongoDB• ………… // Adding an employee document to the employees collection in MongoDB connection_string = "mongodb://localhost:27017" connection = pymongo.Connection(connection_string, safe=True) employee = {_id:employeeId, name:employeeName, age:employeeAge, Address: employeeAddress} db = connection.mydatabase employees = db.employees try: employees.insert(employee); except pymongo.errors.OperationFailure: print "oops, mongo error" return False except pymongo.errors.DuplicateKeyError as e: print "oops, employee already in the collection" return False Copyright by A.N.Ranpise. ( 2013. All Rights 16 reserved.
  • 17. Sample code snippets (Python) Querying a collection in MongoDB• ………… // Querying the employees collection in MongoDB connection_string = "mongodb://localhost:27017" connection = pymongo.Connection(connection_string, safe=True) db = connection.mydatabase employees = db.employees try: // find/get Addresses of all employees named ‘john smith’ and atleast 45 years of age employees.find({‘employeeName’: ‘john smith’, ‘employeeAge’: {$ge: 45}}, {‘employeeAddress’:true}); except pymongo.errors.OperationFailure: print "oops, mongo error" return False Copyright by A.N.Ranpise. ( 2013. All Rights 17 reserved.
  • 18. Sample code snippets (Python) Updating one/more documents in a collection• ………… // Updating the employees collection (one/more documents) in MongoDB connection_string = "mongodb://localhost:27017" connection = pymongo.Connection(connection_string, safe=True) db = connection.mydatabase employees = db.employees try: // find/get Addresses of all employees named ‘john smith’ and atleast 45 years of age employees.set({‘employeeName’: ‘john smith’}, {‘employeeAddress’:”101 First street, Marlboro, MA 05515”}); except pymongo.errors.OperationFailure: print "oops, mongo error" return False Copyright by A.N.Ranpise. ( 2013. All Rights 18 reserved.
  • 19. Testing– To test the DB functionality of an application which uses MongoDB • “mongo” shell provides an easy to use tool for interactive queries, updates, inserts, delete ops • “mongo” also provides commands to test functionality related to Aggregation framework and other commonly used MongoDB development features • Test cases required are similar to those used in apps based on SQL databases • Special items for testing: none • “mongo” also useful in optimizing queries – creating and using correct indexes. Use the query “explain()” API Copyright by A.N.Ranpise. ( 2013. All Rights 19 reserved.
  • 20. Useful references– MongoDB Use cases: cases/– Database design considerations in MongoDB applications:– • Replication • Sharding • Security • Administration Copyright by A.N.Ranpise. ( 2013. All Rights 20 reserved.
  • 21. General References••• Other URLs mentioned in previous slides• Forums• Support Copyright by A.N.Ranpise. ( 2013. All Rights 21 reserved.