Jun 10th, 2016
PRE-REQUISITES
Notions of javascript and JSON
______________________________________________
Mongo DB - Intro and Design Tips
What is?
" MongoDB is a scalable, high-performance, opens source, schema-free, document-oriented database"
mongodb.org
mongodb.org
______________________________________________
Mongo DB - Intro and Design Tips
What is?
Created as an engine for big objects storage, not to be a database
Objects instead of rows
______________________________________________
Mongo DB - Intro and Design Tips
mongo db
RDBMS no longer fits nowadays apps
Big Data
Need to easily scale (horizontally)
______________________________________________
Mongo DB - Intro and Design Tips
Mongo db
- Speed
- Performance
- Flexibility
- Scalability
______________________________________________
Mongo DB - Intro and Design Tips
Mongo DB
Not concerned with transactional stuff and relational semantics
Traditional RDBMS - Data storage is agnostic
______________________________________________
Mongo DB - Intro and Design Tips
Mongo DB
MongoDB tries to achieve the performance of traditional key-value stores, while maintaining functionality of traditional RDBMS
Transactions, constraints are not supported
______________________________________________
Mongo DB - Intro and Design Tips
Mongo DB
______________________________________________
Mongo DB - Intro and Design Tips
Terminology
RDBMS vs MongoDB
Database Database
Table Collection
Row Document
Index Index
Join Embedded
Document
Foreign Key Reference
______________________________________________
Mongo DB - Intro and Design Tips
DOCUMENTS
JSON objects
{ 'user' : 'tbonfim', 'age': '28', 'address': [...]}
______________________________________________
Mongo DB - Intro and Design Tips
MONGO db
Schema-less
You can change the way you store your data on the fly
______________________________________________
Mongo DB - Intro and Design Tips
______________________________________________
Mongo DB - Intro and Design Tips
Sharding
Horizontal scaling
Easily split your data into several servers
Usually better scalability than RDBMs
______________________________________________
Mongo db
Support with major languages
Strong and mature Application-level frameworks to handle what is left behind ( Transactions, constraints)
______________________________________________
Mongo DB - Intro and Design Tips
References
http://mongodb.org
http://www.mongodb.org/display/DOCS/Tutorial
______________________________________________
Mongo DB - Intro and Design Tips
Schema design
- Documents
- Strategies
- Relationships between documents
Schema Design
When designing:How we gonna manipulate the data?
what pieces of data are used together?
Application-Driven Schema
Access Patterns
Read/write Ratio
Types of updates
Types of query
Data life-cycle
Normalization
It's possible, but (often) not recommended
As time goes by we tend to denormalize applications
No constraints
Aggregation! Nested docs
Normalization
Normalized data ( RDBMS ) => Data Storage is king!
Denormalized data ( MongoDB ) => How you use the data is king!
Relationships
Embed vs Reference
Reference -> Easy to cherry-pick pieces of data
Embed -> Keeping it together gives a better speed rate
Size limit!
Size limit!
Rule of thumb
If there's a lot of it => keep it in a separate collection
If there's a limited amount of it => embed it
Indexing
USE INDEXES!
Cover all queries!
Everything possible using indexes!
We have Multikey indexes !
Indexes inside arrays/Nested Docs;
Schemaless
Don`t be afraid, try!
YOU CAN ALWAYS CHANGE YOUR DATABASE!
Real world application
MongoDB - Introduction and design tips
By Thiago Oliveira Bonfim
MongoDB - Introduction and design tips
A presentation about MongoDb and some design tips, with examples in a real world application.
- 990