In todays time when starting a new project you no longer have to choose only between RDBMS’s for software development despite a number of products are created (NoSQL) to offer new approaches to data persistence . Among them some offer better read-write performance than classical storage , some offer near-linear horizontal scalability and some focus on better data representation for more convenient data access for business domain.
MongoDb is one such NoSQL storage that supports sharding , replication and document-oriented persistence. MongoDB is the leading open source, document oriented and cross-platform schemaless NoSQL Database developed by 10gen. It provides subscriptions , consulting , and training for the NoSQL database.
In MongoDB structured data is stored as JSON-like documents associated with dynamic schemas unlike it is stored in form of tables in classical relational database, thereby making data integrations much faster and easier. Unlike MySQL which is written using SQL queries, Mongodb is focused on BSON i.e binary JSON which means that much of the functionality can be directly accessed through JavaScript Notation.
MongoDb comes with its own shell interface to directly run commands onto database. It focus more on objects containing key value pairs.
NoSQL is a vague term that comprises of different types of database engines . It main classes include Graph databases , Column databases , Key/value stores and document databases.
Examples of Graph databases are Neo4j and OrientDB , these model depicts the relations between entities . Cassandra and Hadoop are Column databases and are used for processing large amounts of data . memcache or Redis belong to key/value stores where data is stored and retrieved by a specific key . Lastly MongoDb and Apache CouchDb belongs to the last Document database category.
Document Database -
In a document database(MongoDb) the smallest unit is a document. Every record in MongoDB is a document composed of field and value pairs , it is a data structure more or less similar to JSON objects. The value here can include arrays or arrays of documents . Documents are stored inside a collection which together makes a database. There are many advantages of documents like it corresponds to native data types in many programming languages , dynamic schema supports polymorphism and embedded arrays and documents reduce any need for expensive joins.
Not every document is required to have the same structure each can have different fields or even sub documents normally described as nested or embedded documents .The document database allows to easily retrieve the objects without threading data together to form a valid object.
Why to choose MongoDB :-
1. MongoDB is free and Open source - It is open source and with new releases and updations it is still stable with nice documentations and a growing community. With each new updations new functionalities are being added at rapid pace.
2. Schemaless and Document Oriented - Mongo has no schema and hence makes it a perfect choice for rapid software development as you need not spend time doing schema design . Unlike relational database it stores data in collection of BSON documents which simplifies the mapping between database and domain objects . Arrays and nested objects are transparently stored in the DB making it an apt choice for domains with polymorphic data.
3 . Querying & Aggregation Framework - Mongodb provides a powerful querying facility , which uses indexes that you have created to query nested or embedded objects and arrays . For query that requires MAX , AVG or GROUP BY from SQL , mongo offers a new mechanism Aggregation framework , that allows to run ad-hoc aggregation queries without any need to write cumbersome scripts .
4. Horizontal Scalability - Mongodb provides replication and sharding features to build a clustered topology where replication provides consistent read scaling while sharding facilitates read and write scaling.
5. Intuitive architecture - Mongodb has a single master per replica making it simpler compared to other peer to peer architectures , it also offers fast writes for quick collection of various statistics in a shorter response time .
6. Multiple PL Support - A large no. of programming language can leverage mongodb from ruby to java to php.
7. MapReduce - It is a powerful searching algorithm for aggregations and batch processing similar to hadoop. Massive aggregation is carried out by it, in mongo map and reduce functions are written in javascript and are executed on mongod servers and results are collected on result collections.
Mongodb even provides incremental MapReduce, it allows to run mapreduce jobs over collections,this can lessen the work by merging new data into existing results collection .
8. Role Based - It allows to assign security policies to server and database and other cluster organization .
9 . Mongodb offers replica sets for better fault tolerance and support for large amounts of data in larger environments. In these replica sets , all nodes are copies of one another and there is no single point of failure.
10. Mongodb features a large community with higher level ORM libraries that provides a closer mapping of objects .
MongoDb is mostly preferred and is best used while testing a new application to see how to structure a database with free form objects. Mongo is rich with drivers for nearly all languages including Perl, .NET , PHP, Python,C/C++, and Node.js.
Key Features of MongoDB -
- High Availability - Replica sets which is mongodb’s replication facility is responsible for its high availability . It provides data redundancy and automatic failover.
- High Performance - Mongodb supports embedded data models that reduces input/output activity on DB. Mongodb being a document database has no joins and transactions making the queries much simpler ,also Indexes supports faster queries .
- Automatic Scaling - Sharding provides scalability in mongodb . It distributes the large chunk of data into small clusters and allows horizontal scaling. Sharding can also be termed as partitioning . Mongodb can change partitions for data distribution and load balancing and allows to elastically add new nodes.
Apart from all the benefits Mongodb offers it comes with few flaws that should also be considered while adopting it for your business .
Since mongo is a NoSQL technology so if there is need to select related data from different collections then it has to be done manually which offers slight inconsistency. Moreover ACID transactions won’t be there anymore hence no automatic rollbacks , but this can be overcomed with two-phase commit , in-app locks and entity versions . MongoDB like many RDBMS’s is not optimized to work on HDD , it performs well when your indexes fit into RAM and your SSD hard drives on prod servers.
For setting up MongoDB with Authentication on Windows follow this Blog and for authentication on Ubuntu follow this .
To discuss how we can help you, please contact with our team at info@oodlestechnologies.com or skype : oodles.tech .
No comments:
Post a Comment