Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Saturday, September 20, 2014

MongoDB CRUD Operations

               
       MongoDB CRUD stands for Create, Read, Update, Delete. MongoDB provides rich semantic to communicate with the database. MongoDB CRUD operations are much similar to SQL create,select,update and delete operations. If you already work with SQL you will find it very easy to understand and if your not then still you will find it very easy! OK, before moving forward to CRUD operation we have to understand how MongoDB stores data. As we know MongoDB is document oriented database it stores the data in the form of documents.
      So no rows and columns. It uses JSON(JavaScript Object Notation) like format to store data. Formally, MongoDB documents are BSON documents. BSON is a binary representation of JSON with additional type information. following image is example of MongoDB document.

     Above document shows fields and values which is much similar to the relational database table but MongoBD uses dynamic schema means you not need to specify datatype, fields before entering data into database such as relational database management system. Following image is example of tabular database.
 In MongoDB there are collections instead of table. In MongoDB database contains number of collections MongoDB stores all the documents in collection. Collection is a group of related documents that have a set of shared common indexes.

Now lets see MongoDB CRUD operations, Mainly include MongoDB read operation and Write operation. It contains some important points such as Cursor, query optimization and distributed queries but we will perform simple operations first for better understanding.
    We will perform the tasks in following order :
  1. Create 
  2. Insert 
  3. Read 
  4. Update 
  5. remove
       Before start performing this operations we have to setup environment means making connection between "mongod" server and "mongo" client. If you don't know how to startup mongo shell then read my previous blog "Downloading and installing MongoDB on windows" 

1. Create:
   lets start from creating database in MongoDB. Now what you have to do is just enter following command on mongo shell,
   Syntax:
          use databasename
  Example:
        use blogdata 
   Database is not created unless you not inserting documents in it.


2. Insert:
     To write into database following syntax is used,
 Syntax:
             db.collectionname.insert({ document to be inserted});

      You can use any other folder name instead of "db" if you want.You don't have to create collection separately. It will automatically get created.
 example:
            
                             

            
        To see the document that you have inserted run this command "db.collectionname.find()", "collectionname" should be the same which you have used earlier to insert document.


  3. Read:
           To read data from the database following command is used,
   Syntax:
                 db.collectionname.find();
    By using this command documents will get displayed, you can be more specific by writing some criteria in find(), by default it will display all documents that contains in collection. But if you want to get specific document then Mongo provides way to write more optimized query you can use :

  • Limit the cursor means you can limit the number of result you get which matches criteria.
  • Can add projections means you can specify which fields you want in result.
  • Can add query criteria 

    Example: 
                      
     This query returns documents in which age is greater than 18. It will display only name and address field because it is specified as "1" if field is "0" then mongo does not display that fields in result. Look at following SQL query which gives same result as mongo query for more better understanding.

         
    4. Update: 
           Update operation is used to modify the documents,
       Syntax:
                  db.collectionname.update({ criteria})
       Example:
            Following query will update the document field "status" as "A" where field "age" has value greater than "18".

     Following SQL query gives the same result as mongo.

     
   5. Remove: 
        Remove operation is used  to delete documents from database,
     Syntax:
                      db.collectionname.remove({criteria})
     Example:
         Following query will remove the documents where "status" field is "D".


   See the SQL query for same operation, 

Tuesday, October 1, 2013

Getting Android 4.3 on Samsung Galaxy S2 GT-i9100 -- Part 1

Part 1 - Rooting Your Phone

Galaxy S2 GT-i9100



All the people who have Samsung Galaxy S2 with them will not be getting an update to Android version 4.3 Jellybean from Samsung Galaxy S2 GT-i9100. But you can always flash the Jellybean firmware by flashing the firmware manually. After flashing you may not get the look of Samsung phone, but you will be having the latest firmware running on your device with the looks of Google Nexus. And its really worth it, as you get all the features of latest version of Android. But the downside is, your phone would be Rooted.

Friday, September 7, 2012

Plug-in : The Power of Web Browser


A normal Web Browser can provide the facility to view only the HTML pages, and to view the other things like animated images, flash videos, PDF files etc, we required thePlug-Ins. 
Plug-in means the softwares which provides the extra facilities to your browser from which we can easily utilize the browser without using any other softwares. When we think about the plug-ins, we have to be consider many things that are, which kind of plug-ins to be installed, what are the advantages of it, does we have to update it etc. The answer is itself a browser, whenever we used browser and if we required any kind of plug-in then the browser automatically suggest you to install that plug-in into your browser.
Popular plug-in in mozilla web browser
Many people think that if we have the other softwares then why we should go for the Plug-ins? The answer is, Plug-ins reduces the access time and speedup the browser as well. As we know that the security is main issue for us, Plug-ins also solves that problem, they check for the viruses and scan each files before access. But to experience the same reliability the Plug-ins should be updated up to date.
So far we discuss on the Technical point now I am discuss on the general things. Many time its happens with us that we have some videos or may be the movies in .AVI, .MKV, .MP4, .WEBM, .FLV etc that is not supported by the Windows Media player, Now the Question is what to do? The solution is again Plug-ins, if you suffering from same problem than simply do one think just right click on the Video file and open with your web browser and you will see the browser is working same as your Video player but the Required Plug-ins should be installed in your browser. The same trick is work for the almost all kinds of files like .PDF, .MP3, .WMA, .JPG, .GIF, just follow the same steps. And if it is not working then its means your browser doesnt have the required plug-ins into it.
This technique is mostly work with the Mozilla Firefox Web Browser.