MongoDB belongs to a new brand of databases known as NoSQL Databases or Schema-less Document Oriented Databases. MongoDB was first introduced in 2009 and has been in very active development since then. Lets first see the difference between NoSQL and SQL databases.
How is NoSQL different from SQL Database
Traditional databases a.k.a RDBMS use relations or tables to structure data. Relations in the form of rows and columns. Where row or tuple stores a complete record of an item. A column represents the collection of all same attributes of the records. Then there are Primary Key and Foreign Key relations. Constraints can be added and you have a proper schema running with data types, data length, allow NULL or NOT NULL etc.
NoSQL databases on the other hand simply do not have any schema. Which means no constraint, no limitation on data types, no maximum length issues. The idea of structuring data is very simple, which is key-value storage. These key-value pairs can further be stored in a Document, which is basically a simple collection with different or similar fields. The details will be covered in later posts.
A major attraction is the ability to store data from objects in programming languages directly without a need to map the data members of objects to column names of the table. NoSQL makes storing data for objects in object oriented language very logical and natural unlike RDBMS where a mapping is required. In short Document databases are the right match for Object Oriented Programs with no translation required. Apart from object oriented tasks, another reason is that many times our data is not always can be structured in the form of rows and columns. Previously designers had to make an artificial structure just to store their data in RDBMS.
NoSQL is good for larger public websites where the user base is very large and the rate of data read and write is very high. Such websites need to grow with time that is they have to be very scalable. Replication is built right into them. A reason for this is that RDBMS databases primarily were developed in the era where data was to be stored on large single servers. This has changed a lot now.
So Which One Wins?
This understanding is not correct that NoSQL is here to replace SQL. No that is not the case, in fact NoSQL databases’ application area is where SQL was not good at. The inspiration of NoSQL databases comes from Google’s BigTable and Amazon’s S3 which are used by these companies for their own storage purpose.
SQL databases still have their strengths and will remain.
MongoDB as an NoSQL Database
The next step is to install MongoDB on our system.