2. What is Mongodb ?
Humongous
{name:mongodb,type:db}
10gen
3. What is Mongodb ?
Non-relational
Json/bson document store
Nosql What is it?
Schemaless , what is schema less? And why?
4. Agenda
Why mongodb is required or where mongodb fits in
Mongodb schemaless architecture
Mongodb and RDBMS
Scalability and performance
Summary
5. Why Mongodb ?
Click to edit to edit Master text styles
Click the outline text format
Where mongodb fits in
− Second level
Second Outline Level
the world?
ThirdOutline Level
Third level
Fourth level Level
− Fourth Outline
Fifth Fifth Outline Level
level
Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
Second level
Third level
Fourth level
Fifth level
6. Why Mongodb ?
Where mongodb fits in the world? to edit the outline text format
Click
− Second Outline Level
Relational based DBMS is not known to be scalable
Third Outline Level
− Fourth Outline Level
You require high end hardware architecture for performance
Fifth Outline Level
when it comes to RDMBS Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
RDBMS data storage is not easy flexible
Second level
Third level
Fourth level
Fifth level
7. Why Mongodb ?
Click to edit the outline text format
Relational db is not known to be very scalable and performance oriented unless if
you have very good hardware but if you go for commodity Outline Level it will still
− Second based server
provide its rich functionality but wont be performance oriented and hence not much
Third Outline Level
scalable − Fourth Outline Level
Fifth Outline Level
Sixth Outline Level
Some softwares like Memcache,redis or other key-value store is very good when it
Seventh Outline LevelClick to edit Master text
comes to performance and scalability but often they provide a limited functionality
styles
Second level
Third level
Fourth level
Fifth level
8. Why Mongodb ?
Click to edit the outline text format
Mongodb fills the gap between these two so its very performance oriented and scalable
− Second Outline Level
and have rich set of functionality too that often comparable to what RDMBS
provides , Third Outline Level
− Fourth Outline Level
It does deliberately though omit few functionality of RDBMS in order to Outline Level
Fifth retain
scalability and performance. Sixth Outline Level
Seventh Outline LevelClick to edit Master text
Mongo db does not support Joins , Transactions and schema less
styles
Second level
We will come to it for more when we gonna discuss difference between mongodb and
relational db in coming section
Third level
Fourth level
Fifth level
9. Schema less
Click to edit the outline text format
Mongodb is schema less
What does it mean − Second Outline Level
Why ?
Third Outline Level
− Fourth Outline Level
Fifth Outline Level
Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
Second level
Third level
Fourth level
Fifth level
10. Schema less
Click to edit the outline text format
And one of reason for it is being schemaless
Is It stores data as json document or in other word as javascript object and object
− Second Outline Level
Often is schemaless one object can have different data andThird Outline Level
type then other.
− Fourth Outline Level
Why object is being stored instead of data?
Fifth Outline Level
Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
Second level
Third level
Fourth level
Fifth level
11. Schema less
Click to edit the outline text format
Why object is being stored instead of data?
− Second Outline Level
Third Outline Level
− Fourth Outline Level
Fifth Outline Level
Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
Second level
Third level
Fourth level
Fifth level
12. Schema less
Click to edit the outline text format
Why object is being stored instead of data?
− Second Outline Level
One size doesn’t fits all Third Outline Level
We often need to interact with data objects in programs instead of data itself
− Fourth Outline Level
No ORM required
Fifth Outline Level
Object and its hierarchy is more closer to programming model. Sixth Outline Level
Seventh Outline LevelClick to edit Master text
styles
Second level
Third level
Fourth level
Fifth level
13. Schema less
Click to edit the outline text format
Schemaless architecture of database
− Second Outline Level
Objects are different to each other
Third Outline Level
Agility − Fourth Outline Level
No Alter table
Fifth Outline Level
Sixth Outline Level
db.students.save({name:“user1”,type:”student”})
Seventh Outline LevelClick to edit Master text
db.students.save({name:”user2”,type:”student”,favsubjects:[ ‘math’,’english’] })
styles
We can change schema of existing document too
db.students.save({name:“user1”,type:”student”,favcolors:[‘blue’,’purple’]})
Second level
We will be discussing more about schema in next Third level relative to
section Mongodb
relational
Fourth level
Fifth level
14. Mongodb & RDMBS
Is mongodb replacement for RDBMS?
When you should consider mongodb over RDBMS?
What are pros and cons using mongodb?
15. Mongodb & RDMBS
What are pros and cons using mongodb?
Tradeoffs
Mongodb provides:
− Flexibility
− Performance
− Scalability
Does not support :
Joins
Transactions
16. Mongodb & RDMBS
Why join and transactions are not being supported?
Cos it has to be scalable and performance oriented. Using
join will limit its scalability and transactions affect
performance.
Transactions often not required until you are building
some secure , real time app which is very transactional.
Though mongodb does provides atomic operations but its
currently limited to one document only.
18. Mongodb & RDMBS
How mongodb exists without join?
And the answer is it support embed.
Mongodb document being json fundamentally , can have
embedded sub-documents with it.
So a json document fundamentally comprised of a
dictionary can have another array and even other
dictionaries embedded to it.
e.g :
{
post : “abc”,
19. Mongodb & RDMBS
Embed ? Isn't it violating normal form rules?
It Does and it could be beneficial or harmful depends on
when you are using it.
When to embed or not?
20. Mongodb & RDMBS
When to embed or not?
When to embed:
. If it is being often accessed with main document, then
embed it.
. If change to embedded document is most likely not to be
done
When not to embed:
If size of document is going to be over 16 mb.
{
21. Mongodb & RDMBS
• When you should consider mongodb over RDBMS?
If your DB is 3NF and you don’t do any joins (you’re just
selecting a bunch of tables and putting all the objects
together, AKA what most people do in a web app),
MongoDB would probably for you.
22. Mongodb & RDMBS
Is mongodb replacement for RDBMS?
Its not when your application fall in below Categories:
High transactional applications
Ad-hoc business intelligence
Problems which require a sql solution
23. Scalability and performance
Scalability:
Bigdata
Replications
Fault-tolerence
High-availability
MongoDB provides two types of scaling.
Read scaling: is provided by Replica Sets.
Write scaling is provided by Sharding.
24. Scalability and performance
Scalability:
Replica sets:
A MongoDB replica set is a cluster of mongod
instances that replicate amongst one another and ensure
automated failover
Sharding:
MongoDB’s sharding system allows users to partition a
collection within a database to distribute the collection’s
documents across a number of mongod instances or shards
, sharding is often termed as load-balancing feature of mongodb
to ensure high traffic insert wouldn’t affect performance.
25. Scalability and performance
Mongodb and performance:
Is it comparable to RDMBS? Mysql?
Point is it has got all and sometimes even more, that
required for being a performance oriented dbms.
and it depends on how you design your db.
Support indexes
Support distributed db architecture
Most of the case mongodb is faster and requires less
memory look up round then RDBMS to fetch records.
26. Summary
Mongodb is fast, reliable, scalable database management
system. The main advantages as mentioned before are
flexibility, scalability and performance , it is promising yet
has some tradeoffs and therefore currently cannot replace
the RDBMs for each situation. It is a different type of
database which can be a solution, based on the
requirements of the situation. It will not replace RDBMs
databases and it might run well side-by-side in the future
27. References
stackoverflow
10 gen wiki
Google
28. Thank you
Anshuman Ravi,
10gen certified mongodb
developer.