Mongo DB - 01 (Intro)


I’m going to learn about mongo DB now. Yes yes, it’ll be from scratch because I don’t know anything about MongoDB. When I want to learn a new technology I first google it and find some background details about it.



“MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability.”

Oh... What is document-oriented. I’ve worked with RDBMS but not this document-oriented databases.

“A document-oriented database is a specific kind of database that works on the principle of dealing with 'documents’ rather than strictly defined tables of information.


The document-oriented database plays an important role in aggregating data from documents and getting them into a searchable, organized form.”

A document-oriented database, as a particular kind of NoSQL database, is able to 'parse’ data from documents that store that data under certain 'keys,’ with sophisticated support for retrieval.

For example, suppose one document has two names, one address, and a list of ages of a home’s occupants. A second document might have four names, two addresses, and no age information. A document-oriented database will take the data in both and store them according to type, able to handle non-fixed length data sets.



Ok, as I learned up to now, Mongo DB has collections and collection holds Documents. Collection is like a table in RDBMS. And a Document is like a tuple in the table.  The document is a set of data with key and value pairs.  Below is a sample of the document.

{
   _id: ObjectId(7df78ad8902c)
   title: 'MongoDB Overview',
   description: 'MongoDB is no sql database',
   by: 'tutorials point',
   url: 'http://www.tutorialspoint.com',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100,
   comments: [     
      {
         user:'user1',
         message: 'My first comment',
         dateCreated: new Date(2011,1,20,2,15),
         like: 0
      },
      {
         user:'user2',
         message: 'My second comments',
         dateCreated: new Date(2011,1,25,7,45),
         like: 5
      }
   ]
}

Ok as I told you earlier collection is like a table in RDBMS. But the table has a defined specific structure. You need to define columns, its data types, etc... And if you want to change the structure of it you can use DMLs (Alter commands).

Here in Mongo, you define your collection and define your data as key-value pairs in a document.  If you want to add another data filed then you can just update the document.
In RDMS tables had relationships, but what about Mongo. I also don’t know about that. I guess there is not because I’ve heard it is not relational. Let’s find it out in the coming posts.




Comments

Popular Posts