mongoDB: Why it should (not) replace your SQL database?

33 %
67 %
Information about mongoDB: Why it should (not) replace your SQL database?
Technology

Published on February 28, 2014

Author: mkowalski8

Source: slideshare.net

Description

Can MongoDB replace SQL, one of the most popular database model in the world? Are we going to not use relational data models in future? The aim of the presentation is to present basic information about the noSQL and MongoDB. It tries to answer this questions by showing interesting possibilites of this noSQL database.

Maciej Miara, February 2014

• Non-relational database model • Easy horizontal scalability • Different data structures: - key-value store - key-value cache - object database - document store - graph store - wide-column store • Denormalization

Source: http://blog.beany.co.kr

• • •

Data structure • • • •

Data structure

Object ID • • ObjectId("507f191e810c19729de860ea") Seconds since the Unix epoch Machine identifier Process id Counter, starts with random value

Schema • • • •

Schema • • •

Schema Second query confirms, that mongo returns null, when attribute is not found in document

Querying embedded data • •

Querying embedded data

Capped collections • • • • db.createCollection("log", { capped : true, size : 5242880, max : 5000 }) • Good for logs or temporary data

Map-Reduce • • • • •

Map-Reduce • • • • • • •

Before Map-Reduce

Map-Reduce • • • • •

Map-Reduce • •

Indexes • • • • • •

Single field indexes Source: http://docs.mongodb.org • May be used on embedded documents • Ascending or descending

Compound indexes • Index put on many fields • Sorting asc/desc for all fields Source: http://docs.mongodb.org

Multikey indexes Source: http://docs.mongodb.org • Index added for all items in array • Multikey compound indexes may hold only one compound index on array

Geospatial indexes • • • •

Geospatial queries • • • • • • •

Geospatial queries • • • • • • • •

Geospatial queries - examples Source: http://docs.mongodb.org

Full text search • • • • • •

Full text search Source: http://docs.mongodb.org Supported languages: danish, dutch, english, finnish, french, german, hungaria n, italian, norwegian, portuguese, norwegian, rommani an, russian, spanish, swedish, turkish

Sharding • • • •

Sharding Source: http://docs.mongodb.org

Shard keys • • •

Shard keys – range keys Source: http://docs.mongodb.org

Shard keys – hash keys Source: http://docs.mongodb.org

Javascript driven • • • •

ACID • • • •

Transaction system • • •

Initial Let’s assume we have: Let’s start! Source: http://docs.mongodb.org

Pending Beginning of operation. From now transaction is in progress Source: http://docs.mongodb.org

Do what you need to do db.accounts.update({name: t.source, pendingTransactions: {$ne: t._id}}, {$inc: {balance: -t.value}, $push: {pendingTransactions: t._id}}) db.accounts.update({name: t.destination, pendingTransactions: {$ne: t._id}}, {$inc: {balance: t.value}, $push: {pendingTransactions: t._id}}) db.accounts.find() Perform operations that should be realized in one step. Here account’s balances are updated.

Committed All operations performed, so transaction is committed properly Source: http://docs.mongodb.org

Remove pending Operations done, no longer pending Result: Source: http://docs.mongodb.org { "_id" : ObjectId("4d7bc97fb8a04f5126961523"), "balance" : 900, "name" : "A", "pendingTransactions" : [ ] } { "_id" : ObjectId("4d7bc984b8a04f5126961524"), "balance" : 1100, "name" : "B", "pendingTransactions" : [ ] }

Done Change transaction state to done Source: http://docs.mongodb.org

Failure reaction • • •

Rollback • •

Journaling • • • •

Write concern • • • • •

Unacknowledged Source: http://docs.mongodb.org

Acknowledged Source: http://docs.mongodb.org

Journal acknowledged Source: http://docs.mongodb.org

Replica acknowledged Source: http://docs.mongodb.org

Some people complain about Mongo, but…

…they just don’t know, why they chose it

• • • • • • „My friend from studies used it” „I was just curious” „Recommended by other company (in their project it worked well)” „Technical (!) client wanted it” „After all-night long party I decided to use it” „I heard that Microsoft/Google/NYT/(fill in any corpo you want) uses it”

Do NOT use Mongo, if you: • like joins • Need really transactional system • Have relational data • Want full ACID without any compromises

Any questions? maciej.miara@skygate.pl

Add a comment

Related presentations

Related pages

mongoDB: Why it should (not) replace your SQL database ...

... (not) replace your SQL database? ... Maciej Miara Slajdy: http://www.slideshare.net/mkowalski8/mongodb-why-it-should-not-replace-your-sq
Read more

Why You Should Never Use MongoDB « Sarah Mei

Why You Should Never Use MongoDB. ... I do not build database engines. ... I’m not saying that you should ditch away your RDBMS and use Riak instead, ...
Read more

Pros and Cons of using MongoDB instead of MS SQL Server ...

Pros and Cons of using MongoDB instead of MS SQL ... my MS Sql Server database to MongoDB. ... into your RAM. If not, then you should consider a ...
Read more

database - When would someone use MongoDB (or similar ...

... Why should I use document based database instead of ... MongoDB isn't meant to replace SQL. ... and when your querying needs are not too ...
Read more

Reasons for and against moving from SQL server to MongoDB

Reasons for and against moving from SQL server to MongoDB. ... In my opinion the format of your data should be ... Your database resembles your classes not ...
Read more

Which NoSQL database should I use to replace a ... - Quora

Which NoSQL database should I use to replace ... (although not as rich as SQL and certainly not similar) so your SQL ... to MongoDB queries. It should ...
Read more

Choosing a non-relational database. MySQL to MongoDB ...

Why we chose MongoDB. ... Our reasons for moving to MongoDB were not performance, ... How are you backing up your 800GB MongoDB database?
Read more

MongoDB for GIANT Ideas | MongoDB

MongoDB for GIANT Ideas ... Access and manipulate your data in sophisticated ways, ... NoSQL Database Explained. MongoDB Architecture Guide.
Read more

NoSQL Databases Explained | MongoDB

... may not improve the overall experience of your end ... NOSQL Databases; Types: One type (SQL database) ... SQL Server, Oracle Database: MongoDB, ...
Read more