RK !

Let's make comprehension easy ...

100%x200

Mongo DB

Author: Romaan, Last Updated: March 1, 2017, 8:18 p.m.

Mostly whenever people thought of databases in past, they thought of some database management system like Oracle Database, MySQL Database or PostgresSQL. But today we got many databases that do not adhere to ACID philosophy. One such database is MongoDB.

Mongo is an open source open source document database. Data is stored as a document and documents are grouped into collections. Collections are analogous to tables in relational databases. However, there is no particular schema for the collection.

Every document has '_id' field that acts a primary key

Mongo DB offers shell to access documents and collections. To drop into the shell, type mongo. Inside the mongo shell, the following commands can be used to access and create:

  • help                      # Shows the commands available in Mongo Shell
  • show dbs              # Shows the databases available
  • use <db_name>   # Select the database
  • show collections   # Shows all the collections within the databases

Below commands show a few CRUD operations:

  • Create a document
            db.people.insert({name:'John', age: 12})

The above command creates a document and stores it in collection called 'people'. The document is not restricted by any column names.

  • Update document
  • Find document
db.people.find({name:'John'})

Returns all the document that has name attribute and value 'John'

  • Sort document 

 

Popular Tags:


Related Articles:


Comments: