In this MongoDB tutorial we will discussing about NoSQL databases (i.e. NoSQL as name suggest a database which no SQL and relations between to others database tables, these databases just as simply document formatted and requirement only is storage to hard drive).
NoSQL is a non-relational database management systems, different from traditional relational database management systems in some significant ways. It is designed for distributed data stores where very large scale of data storing needs (for example Google or Facebook which collects terabits of data every day for their users). These type of data storing may not require fixed schema, avoid join operations and typically scale horizontally.
Schema-free DB: A database schema is the structure of database system, described in a formal language supported by the database management system. In a relation database the schema defines the tables, the fields in each table and the relationships between fields and tables, generally it stored in a data dictionary. In NoSQL, collection is a group of documents where document represent a row and collection represent a table in a relational database. Collections are schema free which means within a single collection different types and structured of documents can be stored.
For example, both of the following documents can be stored in a single collection.
{“name” : “dinesh”} {“salary” : 50000} {“address” : “noida”}
Note that the previous documents have no common data elements at all. This flexibility means that schema free practice can be possible in NoSQL database.
Horizontally scalable : To scale horizontally means to add more nodes to a system (such as adding a new computer). In NoSQL system, data store can be much faster as it takes advantage of “scaling out” which means to add more nodes to a system and distribute the load over those nodes.
1.Document Based DB:
Data is stored as documents.
An example format may be like – Employee Name=”Dinesh”, Employee Address=”Noida”, Spouse=[{Name:”Sweety”}], Salary=”50000″
such databases are CouchDB, Jackrabbit, MongoDB, OrientDB, SimpleDB, Terrastore etc.
2.XML Based DB:
Data is stored in XML format.
such databases are BaseX, eXist, MarkLogic Server etc.
3.Graph Based DB:
Data is stored as a collection of nodes, where nodes are analogous to objects in a programming language. Nodes are connected using edges.
such databases are AllegroGraph, DEX, Neo4j, FlockDB, Sones GraphDB etc.
MongoDb is a Open Source database written in C++.
If the load increases, by adding more nodes (such as a computer), the performance can be retained.
It can be used to store data for very high performance applications (for example Foursquare is using it in production).
MongoDb stores data as documents. So it is a document oriented database.
Employee Name=”Dinesh”, Employee Address=”Noida”, Spouse=[{Name:”Sweety”}], Salary=”50000″
Notice there are two different documents (separated by “.”). Storing data in this fashion is called as document oriented database.
1. Since MongoDb offers a Document oriented storage, It is simple and easily programmable.
2. You can set an index on any attribute of a MongoDb record (as Employee Name=”Dinesh”, Employee Address=”Noida”, Spouse=[{Name:”Sweety”}], Salary=”50000″, with respect to which, a record can be sort quickly and ordered.
3. You can set mirror across local as well as wide area networks, which makes it easily scalable.
4. If load increases (more storage space, more processing power), it can be distributed to other nodes across computer networks. This is called as sharding.
5. MongoDb supports rich query to fetch data from the database.
6. MongoDb supports replacing an entire document (database) or some specific fields with it’s update() command.
7. MongoDb supports various programming languages like C, C# and .NET, C++, Erlang, Haskell, Java, Javascript, Perl, PHP, Python, Ruby, Scala (via Casbah).
8. It supports Server-side JavaScript execution. Which allows a developer to use a single programming language for both client and server side code.
9. MongoDb is easily installable.
References-
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…