Introduction- mongoDB.

Share:

The open-source cross-platform

MongoDB is a free and open-source cross-platform document-oriented database program. 

document database with the scalability and flexibility that you want with the querying and indexing that you need.

 document database with the scalability and flexibility that you want with the querying and indexing that you need.

Introduction to MongoDB

As a definition, MongoDB is an open source database that uses a document-oriented data model and a non-structured query language. It is one of the most powerful NoSQL systems and databases around today. Since it is a NoSQL database it does not use the usual rows and columns that we so much associate with the relational database management. It is an architecture that is built on collections and documents. The basic unit of data in this database consists of a set of key-value pairs.
Businesses are increasingly finding that MongoDB is ticking all the right boxes when it comes to meeting the business requirements. Here is how:
  • MongoDB provides the right mix of technology and data for competitive advantage
  • It is the most suited for mission-critical applications since it considerably reduces risks
  • It increasingly accelerated the time-to-value and lowers the total cos.t of ownership
  • It builds applications that is just not possible with traditional relational databases








As a definition, MongoDB is an open source database that uses a document-oriented data model and a non-structured query language. It is one of the most powerful NoSQL systems and databases around today
Being a NoSQL tool means it does not use the usual rows and columns that we so much associate with the relational database management. It is an architecture that is built on collections and documents. The basic unit of data in this database consists of a set of key-value pairs.
It allows documents to have different fields and structures. This database uses a document storage format called BSON which is a binary style of JSON style documents.
The data model that MongoDB follows is a highly elastic one that lets you combine and store data of multivariate types without having to compromise on the powerful indexing options, data access and validation rules. There is no downtime when you want to dynamically modify the schemas. So what it means that you can concentrate more on making your data work harder rather than spending more time on preparing the data for the database.
eliot horowitz
“Users love MongoDB because it offers the fastest time to value compared to any other DBMS technology.” – Eliot Horowitz, developer of MongoDB

History of MongoDB

MongoDB saw its genesis in the middle of 2000 as part of an attempt to decipher all the NoSQL records coming thick and fast. One of its basic features is the support for dynamic schema design. It allows documents to have different fields and structures. This database uses a document storage format called BSON which is a binary style of JSON style documents. There are several examples of  MongoDB data types like double, string, object, array and so on. It provides horizontal scalability using automatic sharding that lets data to be distributed across multiple systems in a collection.

Features of MongoDB

1) Supports ad-hoc queries
2) Any field in the document can be indexed
3) It supports Master slave replication.
4) The database can run over multiple servers. Data is duplicated to foolproof the system in case of hardware failure.
5) Due to sharding MongoDB has an automatic load balancing feature
6) Supports MapReduce and aggregation tools
7) Easy to administer in case of failures
8) Without complicating your stack any sizes of files can be stored
9) It is schemaless written in C++
10) It uses BSON format which is a JSON like format
11) The combination of MongoDB JavaScript works well as the database uses the language instead of procedures.

What is NoSQL?

NoSQL encompasses a wide variety of different database technologies that were developed in response to the demands presented in building modern applications:

  • Developers are working with applications that create massive volumes of new, rapidly changing data types — structured, semi-structured, unstructured and polymorphic data.

 

The Need for NoSQL

Relational databases were never designed to cope with the scale and agility challenges that face modern applications – and aren't built to take advantage of cheap storage and processing power that's available today through the cloud. Relational database vendors have developed two main technical approaches to address these shortcomings:

What are the advantages of MongoDB?

You ought to know why technocrats project MongoDB as one of the best NoSQL databases.


Let’s visit on the 6 aspects through which we can realize the benefits of MongoDB :

Distributed Data Platform – Throughout geographically distributed data centers and cloud regions MongoDB can be run ensuring new levels of availability and scalability. With no downtime and without changing your application MongoDB scales elastically in terms of data volume and throughput. The technology gives you enough flexibility across various data centers with good consistency.


Dynamic schemas

Relational databases require that schemas be defined before you can add data. For example, you might want to store data about your customers such as phone numbers, first and last name, address, city and state – a SQL database needs to know this in advance.
This fits poorly with agile development approaches, because each time you complete new features, the schema of your database often needs to change. So if you decide, a few iterations into development, that you'd like to store customers' favorite items in addition to their addresses and phone numbers, you'll need to add that column to the database, and then migrate the entire database to the new schema.
If the database is large, this is a very slow process that involves significant downtime. If you are frequently changing the data your application stores – because you are iterating rapidly – this downtime may also be frequent. There's also no way, using a relational database, to effectively address data that's completely unstructured or unknown in advance.
NoSQL databases are built to allow the insertion of data without a predefined schema. That makes it easy to make significant application changes in real-time, without worrying about service interruptions – which means development is faster, code integration is more reliable, and less database administrator time is needed.

Auto-sharding, replication and integrated caching

Because of the way they are structured, relational databases usually scale vertically – a single server has to host the entire database to ensure reliability and continuous availability of data. This gets expensive quickly, places limits on scale, and creates a relatively small number of failure points for database infrastructure.
The solution is to scale horizontally, by adding servers instead of concentrating more capacity in a single server. Cloud computing makes this significantly easier, with providers such as Amazon Web Services providing virtually unlimited capacity on demand, and taking care of all the necessary database administration tasks. Developers no longer need to construct complex, expensive platforms to support their applications, and can concentrate on writing application code. In addition, a group of commodity servers can provide the same processing and storage capabilities as a single high-end server for a fraction of the price.

We have provided setup instructions for Mac and Windows operating systems. If your computer notifies you of any firewall or permissioning issues, you should Allow the process.
SET UP MONGODB :

MAC OS X

  1. Open a new terminal session.
  2. Check if Homebrew is already installed on your computer — Homebrew is software that your computer uses to install other software. We will use it to install MongoDB. Run the following command in your terminal to check if Homebrew is already installed: 

    $ brew -v 

       - If your computer does not have Homebrew, it will respond with command not found. If you see this, move to step three. 
       - If Homebrew is installed, your terminal will output Homebrew 1.x.x. If you see this output, check the version of your operating system. If your operating system is High Sierra, you must uninstall brew, then proceed to step 3 — High Sierra introduced a permissioning issue that impacts old versions of homebrew. 
       - If you see Homebrew 1.x.x and have not updated to High Sierra, skip to step 4.
  3. Homebrew Installation — Paste the command from the Homebrew installation page into your terminal. The terminal may ask you to enter your password. This step may take a few minutes.
  4. MongoDB Installation — Paste the following command into your terminal to install MongoDB to your computer.

    brew install mongodb 
  5. Create a Mongo data directory — This directory is where MongoDB stores database files for full-stack web applications that you run on your computer. Paste the following command into your terminal to create the Mongo data directory:

    mkdir -p ~/data/db

    You will not see any output in your terminal from the command above. It will create a new folder in your Home Directory.
  6. Start a Mongo process — Before you run a full-stack web application locally, you must start a Mongo process in the background. The following command starts an instance of MongoDB that handles data requests, manages data access, and performs background management operations while you use your web application. If you are prompted with a popup that says, "Do you want the application mongod to accept incoming network connections?", click Allow.

    mongod --dbpath ~/data/db

    If Mongo starts correctly, you should see something like:

    connection accepted from ... #1 (1 connection now open)

    Nice Job! You just started an instance of MongoDB.
  7. How to kill a Mongo process — When you're done using your Mongo process, or think your current process has gotten into a bad state, navigate to the window that is running your Mongo process and press CTRL-C to exit the Mongo process.

WINDOWS

  1. Download — Open the MongoDB download center page, and download the latest "Community Server" version of MongoDB for your Windows machine.
  2. Install — Open the installation file that you downloaded. Follow the steps to install MongoDB on your computer.
  3. Create a Mongo data directory — This directory is where MongoDB stores database files for full-stack web applications that you run locally. Open powershell, and enter the following command to create the Mongo data directory:

    md \data\db
  4. Start a Mongo process — Before you run a full-stack web application locally, you must start a Mongo process in the background. The following command starts an instance of MongoDB that handles data requests, manages data access, and performs background management operations while you use your web application. Replace X.Xwith the version number you downloaded, like 3.6 for example.

    & 'C:\Program Files\MongoDB\Server\X.X\bin\mongod.exe' 

    If Mongo starts correctly, you should see something like: 

    connection accepted from ... #1 (1 connection now open)
  5. How to kill a Mongo process — When you're done using your Mongo process, or think your current process is in a bad state, navigate to the window that is running Mongo and press control and the letter c(CTRL-C) to exit the Mongo process



Create Operations

Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection.
MongoDB provides the following methods to insert documents into a collection:
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a singledocument.
The components of a MongoDB insertOne operations.
For examples, see Insert Documents.



Read Operations

Read operations retrieves documents from acollection; i.e. queries a collection for documents. MongoDB provides the following methods to read documents from a collection:
You can specify query filters or criteria that identify the documents to return.
For examples, see:

Update Operations

Update operations modify existing documents in a collection. MongoDB provides the following methods to update documents of a collection:
In MongoDB, update operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.
You can specify criteria, or filters, that identify the documents to update. These filters use the same syntax as read operations.
The components of a MongoDB updateMany operation.
For examples, see Update Documents.

Delete Operations

Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:


HOW MONGODB IS CHANGING THE BUSINESS OF BIG DATA

Modern data is vast, unstructured, and sometimes unwieldy. It’s big and complicated, and we have big expectations for what it can do—and trying to store, process, and analyze all of it has led to the development of NoSQL databases. These document-based databases eschew the table-based structure of relational databases and let you group data more logically—read more about this in our Guide to Database Technology article.
The leading NoSQL database, MongoDB, has come out ahead in the field for a few reasons. It’s the database component used in the MEAN software stack, it’s open-source, and it’s cross-platform compatible. It also has some impressive built-in features that make it an excellent choice for businesses that need fast, flexible access to their data, whether it’s to make real-time, on-the-fly decisions, or to create tailored, data-driven experiences for users. It’s not just limited to the MEAN stack, either—it’s compatible with .NET applicationsthe Java platform, and more. It’s been used by organizations like Metlife, ADP, The Weather Channel, Bosch, and Expedia.
When all of the other components of your networked application are designed to be fast and seamless, your data shouldn’t be the bottleneck—and MongoDB is able to meet new data challenges that are difficult (if not impossible) to accomplish well with relational databases. MongoDB enables you to:

  1. Store large volumes of data that often have little to no structure. Relational databases store structured data like a phonebook. But for growing, unstructured data—for example, a customer’s preferences, location, past purchases, and Facebook likes—a NoSQL database sets no limits, and allows you to add different types of data as your needs change. Because MongoDB is flexible and document-based, you can store these JSON-like binary data points (referred to as BSON) in one place without having to define what “types” of data those are in advance.
  2. Make the most of cloud computing and storage. Cloud-based storage is an excellent cost-saving solution, but requires data to be easily spread across multiple servers to scale up. MongoDB can load a high volume of data and give you lots of flexibility and availability in a cloud-based environment, with built-in sharding solutions that make it easy to partition and spread out data across multiple servers.
  3. Develop and release quickly. If you’re developing within two-week Agile sprints, cranking out quick iterations, or needing to make frequent updates to the data structure without a lot of downtime between versions, modifying a relational database will slow you down. With MongoDB’s dynamic schemas, you can try new things, and fast. Your data doesn’t need to be prepped ahead of time, and your team can incorporate anything new, quickly, and at a lower cost.
  4. Scale database architecture efficiently and inexpensively. With MongoDB, it’s easy to spread data out across commodity hardware on-site or in the cloud without needing additional software.
MongoDB is a relatively new contender in the data storage circle compared to giants like Oracle and IBM DB2, but it has gained huge popularity with their distributed key value store, MapReduce calculation capability and document oriented NoSQL features. For more information on MongoDB’s popularity and advantages refer MongoDB: The Database for Big Data Processing

MongoDB has been rightfully acclaimed as the “Database Management System of the Year“ by DB-Engines.

Along with these features, MongoDB has numerous advantages when compared to the traditional RDBMS.  As a result, lot of companies are vying to employ MongoDB database. Here is a look at some of the real world use cases, where organisations, if not entirely, are including it at least as an addition to their existing databases.

Aadhar

Adhar is an excellent example of real world use cases of MongoDB. In recent times, there has been some controversy revolving around CIA’s non-profit Venture Capital arm, In-Q-Tel, backing the company, which developed MongoDB. Putting aside the controversy, let’s look at the MongoDB’s role in Aadhar.

India’s Unique Identification project, aka Aadhar, is the world’s biggest biometrics database. Aadhar is in the process of capturing demographic and biometric data of over 1.2 billion residents. Aadhar has used MongoDB as one of its databases to store this huge amount of data. MongoDB was among several database products, apart from MySQL, Hadoop and HBase, originally procured for running the database search. Here, MySQL is used for storing demographic data and MongoDB is used to store images. According to techcrunch.com, MongoDB has nothing to do with the “sensitive” data.

Shutterfly

Shutterfly is a popular internet-based photo sharing and personal publishing company that manages a store of more than 6 billion images with a transaction rate of up to 10,000 operations per second. Shutterfly is one of the companies that transitioned from Oracle to MongoDB.

During the evaluation at the time of transition to MongoDB, it became apparent that a non-relational database would suit the Shutterfly’s data needs better and thereby possibly improving programmer’s productivity as well as performance and scalability.

Shutterfly considered a wide variety of alternate database systems, including Cassandra, CouchDB and BerkeleyDB, before settling on MongoDB. Shutterfly has installed MongoDB for metadata associated with uploaded photos, while for those parts of the application that require richer transactional model, like billing and account management, the traditional RDBMS is still in place.

Till now, Shutterfly is happy with its decision of transitioning to MongoDB and what Kenny Gorman (Data Architect of Shutterfly) has to say about it is, “I am a firm believer in choosing the correct tool for the job, and MongoDB was a nice fit, but not without compromises.”

MetLife

MetLife is a leading global provider of insurance, annuities and employee benefit programs. They serve about 90 million customers and hold leading market positions in the United States, Japan, Latin America, Asia, Europe and the Middle East. MetLife uses MongoDB for “The Wall”, an innovative customer service application that provides a consolidated view of MetLife customers, including policy details and transactions. The Wall is designed to look and function like Facebook and has improved customer satisfaction and call centre productivity. The Wall brings together data from more than 70 legacy systems and merges it into a single record. It runs across six servers in two data centres and presently stores about 24 terabytes of data. MongoDB-based applications are part of a series of Big Data projects that MetLife is working on to transform the company and bring technology, business and customers together.

eBay

eBay is an American multinational internet consumer-to-consumer corporation, headquartered in San Jose. eBay has a number of projects running on MongoDB for search suggestions, metadata storage, cloud management and merchandizing categorization.


Got a question for us? Please mention it in the comments section and we will get back to you.
MongoDB is a relatively new contender in the data storage circle compared to giants like Oracle and IBM DB2, but it has gained huge popularity with their distributed key value store, MapReduce calculation capability and document oriented NoSQL features. For more information on MongoDB’s popularity and advantages refer MongoDB: The Database for Big Data Processing
MongoDB has been rightfully acclaimed as the Database Management System of the Year by DB-Engines.
Along with these features, MongoDB has numerous advantages when compared to the traditional RDBMS.  As a result, lot of companies are vying to employ MongoDB database. Here is a look at some of the real world use cases, where organisations, if not entirely, are including it at least as an addition to their existing databases.
Aadhar
Adhar is an excellent example of real world use cases of MongoDB. In recent times, there has been some controversy revolving around CIA’s non-profit Venture Capital arm, In-Q-Tel, backing the company, which developed MongoDB. Putting aside the controversy, let’s look at the MongoDB’s role in Aadhar.
India’s Unique Identification project, aka Aadhar, is the world’s biggest biometrics database. Aadhar is in the process of capturing demographic and biometric data of over 1.2 billion residents. Aadhar has used MongoDB as one of its databases to store this huge amount of data. MongoDB was among several database products, apart from MySQL, Hadoop and HBase, originally procured for running the database search. Here, MySQL is used for storing demographic data and MongoDB is used to store images. According to techcrunch.com, MongoDB has nothing to do with the “sensitive” data.
Shutterfly
Shutterfly is a popular internet-based photo sharing and personal publishing company that manages a store of more than 6 billion images with a transaction rate of up to 10,000 operations per second. Shutterfly is one of the companies that transitioned from Oracle to MongoDB.
During the evaluation at the time of transition to MongoDB, it became apparent that a non-relational database would suit the Shutterfly’s data needs better and thereby possibly improving programmer’s productivity as well as performance and scalability.
Shutterfly considered a wide variety of alternate database systems, including Cassandra, CouchDB and BerkeleyDB, before settling on MongoDB. Shutterfly has installed MongoDB for metadata associated with uploaded photos, while for those parts of the application that require richer transactional model, like billing and account management, the traditional RDBMS is still in place.
Till now, Shutterfly is happy with its decision of transitioning to MongoDB and what Kenny Gorman (Data Architect of Shutterfly) has to say about it is, “I am a firm believer in choosing the correct tool for the job, and MongoDB was a nice fit, but not without compromises.”
MetLife
MetLife is a leading global provider of insurance, annuities and employee benefit programs. They serve about 90 million customers and hold leading market positions in the United States, Japan, Latin America, Asia, Europe and the Middle East. MetLife uses MongoDB for “The Wall”, an innovative customer service application that provides a consolidated view of MetLife customers, including policy details and transactions. The Wall is designed to look and function like Facebook and has improved customer satisfaction and call centre productivity. The Wall brings together data from more than 70 legacy systems and merges it into a single record. It runs across six servers in two data centres and presently stores about 24 terabytes of data. MongoDB-based applications are part of a series of Big Data projects that MetLife is working on to transform the company and bring technology, business and customers together.
eBay
eBay is an American multinational internet consumer-to-consumer corporation, headquartered in San Jose. eBay has a number of projects running on MongoDB for search suggestions, metadata storage, cloud management and merchandizing categorization.

Got a question for us? Please mention it in the comments section and we will get back to you.


Why do we need the MongoDB technology?

  • The data storage is document-oriented style and it is done in JSON style documents
  • It offers the benefit of replication and high availability
  • The data can be indexed based on any attribute
  • It is possible to perform auto-sharding of data
  • It offers rich querying options and fast in-place updates
  • MongoDB is professionally supported and by its growing communit.





















NoSQL Databases Ex


2 comments: