Maciej Miara, April 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
•
•
•
•
•
•
•
Data structure
Data structure
•
•
Object ID
ObjectId("507f191e810c19729de860ea")
Seconds since
the Unix epoch
Machine
identifier
Process idCounter, 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
•
•
•
•db.createCollection("log", { capped : true, size : 5242880, max : 5000 } )
• Good for logs or temporary data
Capped collections
•
•
•
•
•
Map-Reduce
•
•
•
•
•
•
Indexes
•
•
•
•
Geospatial indexes
•
•
•
•
•
•
•
Geospatial queries
Geospatial queries - examples
Source:
http://docs.mongodb.org
•
•
•
•
•
•
Full text search
Full text search
Supported languages:
danish, dutch, english, finnish, french, german,
hungarian, italian, norwegian, portuguese, norwegian,
rommanian, russian, spanish, swedish, turkish
Source:
http://docs.mongodb.org
Sharding
•
•
•
•
Sharding
Source:
http://docs.mongodb.org
•
•
•
•
•
•
GridFS
•
•
•
•
Javascript driven
•
•
•
•
ACID
•
•
•
Transaction system
•
•
•
•
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?