Sunday, March 7, 2021

NoSQL & Overview of MongoDB

 👉    What are the types of NoSQL databases?

            1.    Key-value

*    Here the data is stored in key value pairs. Each data is stored in an attribute name and its corresponding value.

*    This has two columns in which the first column is the key and the second column is the value. 

*    Examples :    Redis, Riak, memcached.

            2.    Document.

*    This database type stores data in JSON, BSON or XML documents.

*    Its is the most common database type. The popular MongoDB is the type of document database.

*    Document databases are flexible to rework the modify structures according to the application, shaping their data structures as their application requirements change overtime.

            3.    Column-family.

*    Store data in column families.

*    Columns are grouped according to the data and organized to columns appropriately. This helps to read the columns directly without consuming memory.

            4.    Graph.

*    This database type focuses on the relationship between the data elements.

*    This is much similar to a relational database which the connections between the data elements are called links or relationships.

*    This database organize the data elements along with its relationship in a analytics format which is easy to understand and grab the database content.  

*    The example for a graph database is Neo4j.

Read more on NoSQL database types


 👉    Mongo Database.



            1.    Features of MongoDB.
                
                   *    This is a type of document NoSQL database.
                   *    Uses the spidermonkey JS engine.
                   *    This contains a in-built storage named grid file system.

        2.    Special documents of MongoDB.
                
               *    Multi-document transactions.
               *    Indexing capabilities.
               *    In memory storage engine.
               *    Sharding.

       3.    Using MongoDB.
            
               *    Install MongoDB enterprise community to the local machine.
               *    Use studio3T or Robo3T to work with MongoDB.
               *    Use the online MongoDB Atlas.

       4.    Some basic MongoDB commands(in studio3T).

               *    Create a database called university.
                     use university
                
               *    Create a collection (table) called student in the database university and insert document                         (record in table).
                     db.student.insertOne({name:"John", address:"Kandy", age:"20"})
                     db.student.insertMany({name:"John", address:"Kandy", age:"20"},
                                                          {name:"Jane", address:"Colombo", age:"20"})


               *    Open a document in collection.
                     (Retrieve all the documents in the collection)
                     db.student.find()
                     (Retrieve specific document in the collection)
                     db.student.find({name:"John"})

               *    Remove document in collection.
                     db.student.remove()

               *    Update document in collection.
                     db.student.update({name:"John"},{$set:{address:"Galle"}})

               *    Update an array and new value to array.
                      db.student.update({name:"John"},{$push:{subjects:"Galle"}})   

                        

No comments:

Post a Comment

Monolithic vs Microservices

👉     Monolithic Architecture. *     Monolithic architecture was there before Microservices came into action.  *     All functionalities or...