NoSQL MongoDB
Agenda:
- What is NoSQL?
- NoSQL types
- Why NoSQL?
- Why MongoDB?
- Install MongoDB
- SQL terms in MongoDB
- Data Modeling
- Queries
What is NoSQL?
Not only SQL
NoSQL types:
- Document
- MongoDB
- CouchDB
- Key-Value Pair
- Redis
- Cassandra
- Graph
- Neo4j
- HyperGraphDB Popular NoSQL Database: http://nosql-database.org/.
Why NoSQL?
- More scalable then RDBMS
- Can Handle large volumes of Data
- Much faster then RDBMS
Why is MongoDB?
- Rich query model.
- Full Index Support
- High Performance.
- Vertical + Horizontal scalable.
- Geospatial support.
- Map-Reduce.
- Professional Support by MongoDB.
Install MongoDB
http://docs.mongodb.org/manual/installation/.
SQL terms in MongoDB
SQL | MongoDB |
---|---|
Database | Database |
Table | Collection |
Row | Document |
Column | Field |
Data Modeling
Queries
- To start MongoDB shell/client:
mongo
. - To list database names:
show dbs
. - To select a database:
use dbName
. - To list all the collection names:
show tables
orshow collections
. - To insert a document:
db.collectionName.insert({name:'Amit', age:27})
. - To update a document:
db.collectionName.update({name:'Amit'}, {name:'Amit Thakkar'})
. - To upsert a document:
db.collectionName.save({name:'Amit'})
. // Update will happen if _id matched. - To remove a document:
db.collectionName.remove({name:'Amit'})
. - To read a document:
db.collectionName.find({name:'Amit'})
.