The agenda of the slides are to discuss some basic and in-depth details of MongoDB and NoSQL.
A snapshot of the topics discussed:
- Introduction to NoSQL and MongoDB
- Installation
- Queries
- Indexing
- Schema modeling
- Aggregation
This tutorial is an introduction to MongoDB and NoSQL. The tutorial includes an introduction to MongoDb and NoSQL, installation, queries related to MongoDB and NoSQL, aggregation framework, indexing of MongoDB and NoSQL and schema modelling. The tutorial begins with a section on introduction. This section includes an introduction to NoSQL, its data models like document model, graph model, key value etc. It also includes an introduction to MongoDB and its data model.
The introduction section is then followed by the installation section. This section includes installing MongoDB, default directory, starting MongoDB server, starting Mongo shell and more steps. It also includes adding documents. The next section is about queries related to MongoDB and NoSQL. This section includes query collection which are selecting all documents, find by example, use OR condition, use AND condition, update query. It also includes removing documents.
Then comes a section about aggregation framework. This section includes a brief about aggregation framework process and its samples. The next section is about indexing. This section involves indexing for speeding up of search and sorting, types of indexes like single field, compound field, multiple index etc. The last section of the tutorial is about schema modelling. This section includes schema design factors like rich documents, no mongo joins, no constraints, atomic operation etc.
4. Introduction to NoSQL
• Not onlySQL
• Stores and retrieves data with less constrained consistency
model than RDBMS
• More scalable and have finer control over availability.
• Handle large volumes of structured/unstructured data.
• Efficient scale-out architecture.
• Highly optimized key-valuestores
5. NoSQL data models
• Document model
• Uses embedded data thus no joins
• MongoDB and couchDB
• Graphmodel
• Used where relationships are core to app.
• Neo4j and HyperGraphDB
• Key-value and wide column model
• Redis, Riak :Key-value
• Cassandra, BigTable :wide column model
• Popular NoSQLdatabases : http://nosql-database.org
6. MongoDB
• Open source
• Document data model
• Rich querymodel
• Full Index Support
• High performance with highavailability
• Horizontal scalability
• Map/Reduce
• Geospatial support
• Professional Support ByMongoDB
7. MongoDB Data Model
• Stores dataas documents in BSON representation
• BJON extends JSON to include additional types :
-Int, long, floating point, arrays, binary data,sub-documents
8. MongoDB data model continued :
Collection
Collection
Collection
Document
Document
Document
Field
Field
Field
Database
NongoDB Data
Structure
9. Compare RDBMS terms with MongoDB
RDBMS MongoDB
Database Database
Tables Collections
Rows Documents
Columns Key
MongoDB is schema-less. Each document can have different
number of keys(fields) and and store different types of data.
{name :‘Rajeev’, age :45, hobby :[“Cricket”, “Movies”]}
{name :42, age :45, profession : “Software engineer”}
Both the above documents can reside in same collection.
16. Removing documents
• Remove all documents
db.inventory.remove()
• Remove all documents matching specific condition
db.inventory.remove( {type :"food" })
• Removing single document matching condition
db.inventory.remove( {type :"food" },1)
17. Aggregation framework
• Aggregation operations processes data records and returns
computed results
• It group values from multiple documents together and can
perform a variety of operations on the grouped data to return
a single result
19. Speed up search and sorting : Index
• Without index MongoDB must scan every document in a collection
• No additional sort phase is executed if there exist corresponding index
• Results will be returned directly if projection includes only the index fields
• Affects the aggregation framework as well
• Supports variety of index types :geolocation, arrays etc.
20. Types of index
• Default by mongoDB_id
• Single field
db.friends.ensureIndex({“name” :1})
• Compound field
db.events.ensureIndex({“username” :1, date :-1
db.events.find().sort({username:1, date: -1}) #usesindx
db.events.find().sort({username: -1, date: 1})#uses index
db.event.find().sort({username: 1, date:1}) #index not used
Compound indexes support queries on any prefix of the index fields
• Multikey index
• For arrays by default
• Geospatial indexes
• Used by geospatial queries e.g. $near, $centerSphere, $within etc.
21. Schema design factors
• Rich documents
• Pre-join / Embed data
• No Mongo joins
• No constraints
• Atomic operations
• No declared schema
23. Contact us
As the Advanced Consulting
Partners of MongoDB we
have delivered some
amazing MongoDB
development projects,
Know more:
Click Here To Know More!
Have more queries
related to MongoDB?
Talk To Our Experts!
Our Office
Client
Location