Pages

Sunday, April 3, 2016

Mongo DB

What is MongoDB..... ?

  • open source
  • cross platform
  • document oriented
  • leading NoSql database 

  • written in C++

UBUNTU INSTALLATION

  •  Download the MongoDB binary file of the latest technology from the site
        https://www.mongodb.org/downloads

  • Extrace the file from the downloaded archive using the command 
    tar -zxvf mongodb-linux-x86_64-3.2.4.tgz
      
  •   Copy your extracted archive to the installation directory(target directory)
  • Give the location of the MOngoDB installation folder to the PATH variable in bashrc. Add below to the .bashrc file
     export PATH=<mongodb-install-directory>/bin:$PATH
 

  GETTING STRATED

  • navigate to the installation folder
  • go to bin folder in it and type  
           ./mongod --dbpath /data/db
  • take another terminal and type 
          ./mongo
 
 MongoDB configuration file => etc/mongos.conf

 

Important Terminology 

  •  Database  
                       Its a container for collections. Multiple databases resides in   a single MongoDB server.
  • Collection 
                       Group of documents is a collection.Typically documents in a collection are  similar. But documents within a collection can have different fields.

  • Document
                    Set of key-value pairs. Documents have dynamic schema
  • Dynamic Schema 
                     documents in the same collection can have different fields or structure. These documents can have the same field, but values need not to be same. Below shows a sample document structure.

      

 Relationship of RDBMS terminology with MongoDB 

Working with MongoDB

 Below mind-map shows the basic commands when dealing with MongoDB like creating a database, creating a collection, querying  a document etc.





querying a document

    We learnt find() method is used to query a document and find().pretty() to get the display in a formatted way. Below is a screen shot of a simple query


Below shows commands in querying a document on the basis of some condition.
 (in below commands 'mycol' is the collection name)





(hope the update on the following sub topics)

Indexing

Aggregation

Replication

Sharding

 

 

 














No comments:

Post a Comment