Mongo Db - First Look
Definition
Mongo db is a scalable, high-performance, open source, schema-free, document-oriented database.Advantages
Here are some of the advantages of MongoDB for building web applications:- A document-based data model. The basic unit of storage is analogous to JSON, Python dictionaries, Ruby hashes, etc. This is a rich data structure capable of holding arrays and other documents. This means you can often represent in a single entity a construct what would require several tables to properly represent in a relational db.
- Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL.
- No schema migrations. Since MongoDB is schema-free, your code defines your schema.
- Better performance. There are many reasons for this. One is that, since the document model frequently doesn't need joins, MongoDB doesn't support them; another is that MongoDB uses memory-mapped files and a different consistency model.
- A clear path to horizontal scalability.
Steps to start Mongo db
- Run “mongod –dbpath c:\data\db ”
- Start the mongo console by running “mongo” from the mongo bin.
Some basic commands to explore Mongo db
mongos> show dbs
abcdb
xyzdb
mongos> use xyzdb
switched to db xyzdb
mongos> show collections
xyz
mongos>db.xyz.find({})
switched to db xyzdb
mongos> show collections
xyz
mongos>db.xyz.find({})
Steps to import db from a different server
- Connect to mongo console of the server from the local installations with the tunnel settings.
- Run “mongodump” from MONGO_HOME/bin.
- This will generate a dump folder with the backup of all collection from the dev on your local file system in a folder MONGO_HOME/dump.
- Remove tunnel settings and restart mongod and mongo console.
- Run “mongorestore –dbpath C:\data\db” from MONGO_HOME/bin
- This will copy all data files in your local db.
Comments
Post a Comment