Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Experiment No 4

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Experiment No.

Aim : To install and Configure MongoDB to execute NoSQL commands.

Lab Outcome No. : 8.ITL 801.2

Lab Outcome : Program application using tools like Hive, Pig, NoSQL and MongoDB for Big Data Application.

Date of Performance: 14/3/22

Date of Submission:21/3/22

Program formation/ Documentation (02) Timely Submission Viva Answer (03) Experiment Marks Teacher Signature
Execution / Ethical (03) (15) with date
practices (07 )

EXPERIMENT NO : 4

AIM : To install and Configure MongoDB to execute NoSQL commands

THEORY :

What is NoSQL:

NoSQL(Not Only SQL) is a non-relational database management system, different from traditional relational database management systems in some significant ways. It is

designed for distributed data stores where a very large scale of data storing needs These types of data storing may not require fixed schema, avoid join operations and typically

scale horizontally.

Why NoSQL?

In today’s time data is becoming easier to access and capture through third parties such as Facebook, Google+ and others. Personal user information, social graphs, geo location

data, user- generated content and machine logging data are just a few examples where the data has been increasing exponentially. To avail the above service properly, it is

required to process huge amounts of data. Which SQL databases were never designed. The evolution of NoSql databases is to handle these huge data properly.

Benefits of NoSQL over RDBMS:


● SchemaLess: NoSQLdatabasesbeingschema-lessdonotdefineanystrictdatastructure.
● Dynamic and Agile: NoSQL databases have a good tendency to grow dynamically with changing requirements. It can handle structured, semi-structured and

unstructured data.

● Scales Horizontally: In contrast to SQL databases which scale vertically, NoSQL scales horizontally by adding more servers and using concepts of sharding

and replication. This behavior of NoSQL fits with the cloud computing services such as Amazon Web Services (AWS) which allows you to handle virtual servers which can be

expanded horizontally on demand.


● Better Performance: All the NoSQL databases claim to deliver better and faster performance as compared to traditional RDBMS implementations.
Types of NoSQL Databases
● Document OrientedDatabases

Document oriented databases treat a document as a whole and avoid splitting a document in its constituent name/value pairs. At a collection level, this allows for putting

together a diverse set of documents into a single collection. Document databases allow indexing of documents on the basis of not only its primary identifier but also its

properties. Different open-source document databases are available today but the most prominent among the available options are MongoDB and CouchDB. In fact, MongoDB

has become one of the most popular NoSQL databases.


● Graph BasedDatabases
A graph database uses graph structures with nodes, edges, and properties to represent and store data. By definition, a graph database is any storage system that provides index-

free adjacency. This means that every element contains a direct pointer to its adjacent element and no index lookups are necessary. General graph databases that can store any

graph are distinct from specialized graph databases such as triple-stores and network databases. Indexes are used for traversing the graph.
● Column BasedDatabases
The column-oriented storage allows data to be stored effectively. It avoids consuming space when storing nulls by simply not storing a column when a value doesn’t exist for

that column. Each unit of data can be thought of as a set of key/value pairs, where the unit itself is identified with the help of a primary identifier, often referred to as the

primary key. Bigtable and its clones tend to call this primary key the row-key.
● Key ValueDatabases
The key of a key/value pair is a unique value in the set and can be easily looked up to access the data. Key/value pairs are of varied types: some keep the data in memory and

some provide the capability to persist the data to disk. A simple, yet powerful, key/value store is Oracle’s BerkeleyDB.

Popular NoSQL Databases

NoSQL databases that fall in the above categories respectively.


● Document Oriented Databases – MongoDB, HBase, Cassandra, Amazon SimpleDB, Hypertable, etc.

● Graph Based Databases – Neo4j, OrientDB, Facebook Open Graph, FlockDB,etc.


● Column Based Databases – CouchDB, OrientDB,etc.
● Key Value Databases – Membase, Redis, MemcacheDB, etc.

MongoDB

MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collection and

document.
● Database: Database is a physical container for collections. Each database gets its own set of files on the file system. A single MongoDB server typically has

multiple databases.

● Collection: Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database. Collections do

not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purpose.

● Document: A document is a set of key-value pairs. Documents have a dynamic schema. Dynamic schema means that documents in the same collection do not

need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.

MongoDB Installation steps:


Step 1: Install Mongodb on vm:

Step 1.1: Configure the package management system (yum):

Create a /etc/yum.repos.d/mongodb-org-4.2.repo file so that you can install MongoDB directly using yum:

[mongodb-org-4.2] name=MongoDB Repository


baseurl=https://repo.mongodb.org/yu
m/redhat/$releasever/mongodb- org/4.2/x86_64/ gpgcheck=1
enabled=1

gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

Step 1.2 Install the MongoDB packages:

sudo yum install -y mongodb-org


Step 2 Start Mongodb:

Start MongoDB, a default configuration file is installed by yum so you can just run this to start on localhost and the default port 27017

mongod -f /etc/mongod.conf

Step 1 : 1. Download MongoDB

Download MongoDB from the official MongoDB website. Choose Windows 32 bits or 64 bits.

Step 2 :There are two ways of installation of MongoDB,either download and extract zip file in to C drive or download msi package and Install it by double clicking on setup

file which install it in c:/program files directory.

Step 3 : Review MongoDB folder


In MongoDB, it contains only 10+ executable files (exe) in the bin folder. This is true, and that are the required files to MongoDB, it’s really hard to believe

for a developer like me who comes from a relational database background. MongoDB needs a folder (data directory) to store its data. By default, it will store

in “C:\data\db“, create this folder manually. MongoDB won’t create it for you. You can also specify an alternate data directory with --dbpath option.

Step 4 : Run MongoDB server

change directory copy the path of program files till bin...

Open command prompt type following command to start to start MongoDB server. c:\mongodb\bin>mongod //--configc:\
mongodb\mongo.config

Step 5 : Connect client to MongoDB Server by typing mongo on another command prompt

c:\mongodb\bin>mongoMongoDB shell version: 2.2.3connecting to: test

CONCLUSION :

MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. MongoDB obviates the need for

an Object Relational Mapping (ORM) to facilitate development.

OUTPUT :

1. Show Databases:

2. Create Databases:

3. Create Collection:

4. Insert Document:
5. Query Document:

6. Projection:

7. Update Document:
8. Delete Document:

9. Sorting:

Inserting Multiple Documents:


Ascending Order:

Descending Order:

10. Deleting Document:

11. Deleting Collection:

12. Deleting Databases:

You might also like