0% found this document useful (0 votes)
89 views13 pages

Objective: Mongodb Is An Open-Source Database Written in C++. Development of Mongodb Began in

The document discusses setting up a MongoDB database to store player performance data for UEFA Champions League Group A matches in the 2020-21 season. It involves creating a "UEFAChampionsLeague" database and a "Group A Players Info" collection to insert documents for each player with fields like name, position, nationality, date of birth, team, goals, assists, and cards. The data is stored in MongoDB and can be viewed and organized in tables for easy access and analysis by management.

Uploaded by

Sandeep Dhupal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views13 pages

Objective: Mongodb Is An Open-Source Database Written in C++. Development of Mongodb Began in

The document discusses setting up a MongoDB database to store player performance data for UEFA Champions League Group A matches in the 2020-21 season. It involves creating a "UEFAChampionsLeague" database and a "Group A Players Info" collection to insert documents for each player with fields like name, position, nationality, date of birth, team, goals, assists, and cards. The data is stored in MongoDB and can be viewed and organized in tables for easy access and analysis by management.

Uploaded by

Sandeep Dhupal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

1.

OBJECTIVE

The primary goal of the having the records of player performance for the particular season is
to ensure that all the information is accessible whenever the management team needs them or
the users like executives such as managers, ensuring the historical data preservation.

2. PROBLEM STATEMENT

As a data administrator of the UEFA management team, you are responsible for inserting the
documents for the Group A, UEFA Champions League 2020-21 in appropriate collection of
Player Performance.

3. INTRODUCTION TO MONGODB

օ What is MongoDB?

MongoDB is an Open-Source database written in C++. Development of MongoDB began in


October 2007 by 10gen. The first public release was in February 2009.

Drivers and client libraries are typically written in their respective languages, although some
drivers use C extensions for better performance.

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 does not support SQL It supports a rich, ad-
hoc query language of its own.

MongoDB stores data as documents. So, it is a document-oriented database.

FirstName="Arun",
Address="St. Xavier's Road",
Spouse=[{Name:"Kiran"}],
Children=[{Name:"Rihit", Age:8}].
FirstName="Sameer",
Address="8 Gandhi Road".

1
Key Features

Since MongoDB offers a Document oriented storage, it is simple and easily programmable.

 You can set an index on any attribute of a MongoDB record (as


FirstName="Sameer",Address="8 Gandhi Road"), with respect to which, a record can
be sort quickly and ordered.

 You can set mirror across local as well as wide area networks, which makes it easily
scalable.

 If load increases (more storage space, more processing power), it can be distributed to
other nodes across computer networks. This is called as sharding.

 MongoDB supports rich query to fetch data from the database.

 MongoDB supports replacing an entire document (database) or some specific fields


with it's update() command.

 MongoDB supports Map/Reduce framework for the batch processing of data and
aggregation operation. Here is brief of how Map/Reduce works :

 Map : A master node takes an input. Splits it into smaller sections. Sends it to the
associated nodes.

 These nodes may perform the same operation in turn to send those smaller section of
input to other nodes. It processes the problem (taken as input) and sends it back to the
Master Node.

 Reduce : The master node aggregates those results to find the output.

 GridFS specification of MongoDB supports storage of very large files.

 MongoDB supports various programming languages like C, C# and .NET, C++,


Erlang, Haskell, Java, Javascript, Perl, PHP, Python, Ruby, Scala (via Casbah).

 It supports Server-side JavaScript execution. Which allows a developer to use a single


programming language for both client and server-side code.

 MongoDB is easily installable.

2
INSERT DATA IN MONGODB

In this page, we are going to discuss how to insert data into a collection. The documents
stored in MongoDB are JSON-like. All data stored in the collection are in BSON format.
EXAMPLE:

Here, our database is "myinfo".

> use myinfo

switch to db myinfo

The following document can be stored in MongoDB.

{
"user_id" : "ABCDBWN",
"password" : "ABCDBWN",
"date_of_join" : "15/10/2010",
"education" : "B.C.A.",
"profession" : "DEVELOPER",
"interest" : "MUSIC",
"community_name" : [
"MODERN MUSIC",
"CLASSICAL MUSIC",
"WESTERN MUSIC"
],
"community_moder_id" : [
"MR. BBB",
"MR. JJJ",
"MR MMM"
],
"community_members" : [
500,
200,
1500
],
"friends_id" : [
"MMM123",
"NNN123",
"OOO123"
],
"ban_friends_id" : [
"BAN123",
"BAN456",
"BAN789"
]
}

3
Insert a data into a collection without defining a document

>db.userdetails.insert(
{"user_id" : "xyz123","password" :"xyz123" ,"date_of_join" : "15/08/2010" ,
"education" :"M.C.A." , "profession" : "Software consultant","interest" : "Film",
"community" : [
{
"name" : "DDD FILM CLUB",
"moder_id" : "MR. DBNA",
"members" : "25000",
},
{
"name" : "AXN MOVIES",
"moder_id" : "DOGLUS HUNT",
"members" : "15000",
},
{
"name" : "UROPEAN FILM LOVERS",
"moder_id" : "AMANT LUIS",
"members" : "20000",
}
],
"friends" :[
{
"user_id" : "KKK258",
},
{
"user_id" : "LLL147",
},
{
"user_id" : "MMM369",
}
],
"ban_friends" :[
{
"user_id" : "BAN147"
},
{
"user_id" : "BAN258"
},
{
"user_id" : "BAN369"
}
]
});

4
UPDATE DATA IN MONGODB WITH () FUNCTION

In this page, we are going to discuss how to update data into a collection. The update can be
done with update(). The update() takes four arguments - criteria, objectnew, upsert and multi.

criteria - Query which specify the record to update;


objectnew- Specify the updated information or it can be used by $ operator (i.e., $inc...).
upsert - An upsert do update the record if match the criteria and insert a record if not match.
multi - This argument asks for updates all matching rows or just the first one(which is
default).
Our database name is 'myinfo' and our collection name is 'userdetails'. Here, inserting two
more records.

> document=({"user_id" : "MNOPBWN","password" :"MNOPBWN" ,"date_of_join" :


"16/10/2010" ,"education" :"M.C.A." , "profession" : "CONSULTANT","interest" :
"MUSIC","community_name" :["MODERN MUSIC", "CLASSICAL MUSIC","WESTERN
MUSIC"],"community_moder_id" : ["MR. BBB","MR. JJJ","MR
MMM"],"community_members" : [500,200,1500],"friends_id" :
["MMM123","NNN123","OOO123"],"ban_friends_id" 9:
["BAN123","BAN456","BAN789"]});

> db.userdetails.insert(document)

> document=({"user_id" : "QRSTBWN","password" :"QRSTBWN" ,"date_of_join" :


"17/10/2010" ,"education" :"M.B.A." , "profession" : "MARKETING","interest" :
"MUSIC","community_name" :["MODERN MUSIC", "CLASSICAL MUSIC","WESTERN
MUSIC"],"community_moder_id" : ["MR. BBB","MR. JJJ","MR
MMM"],"community_members" : [500,200,1500],"friends_id" :
["MMM123","NNN123","OOO123"],"ban_friends_id" :
["BAN123","BAN456","BAN789"]});

> db.userdetails.insert(document)

Update() command

If we want to re-write the document into the collection 'userdetails' with a change of
'password' is 'NEWPASSWORD' where 'user_id' is 'QRSTBWN' the following update()
command can be written. If the criteria argument matches with any record the update will
take place otherwise a new record will be inserted. The following example will update the
first matching criteria into the collection.

> db.userdetails.update(

5
{"user_id" : "QRSTBWN"},
{"user_id" : "QRSTBWN","password" :"NEWPASSWORD" ,"date_of_join" : "17/10/2010"
,"education" :"M.B.A." , "profession" :
"MARKETING","interest" :"MUSIC","community_name" :["MODERN MUSIC",
"CLASSICAL MUSIC","WESTERN MUSIC"],"community_moder_id" : ["MR.
BBB","MR. JJJ","MRMMM"],"community_members" : [500,200,1500],"friends_id" :
["MMM123","NNN123","OOO123"],"ban_friends_id" :
["BAN123","BAN456","BAN789"]});

REMOVE DOCUMENT FROM COLLECTION IN MONGODB WITH REMOVE()

We have already learned how to insert records into a collection and also learned how to
update the document within a collection based on certain criteria.

If we want to remove all data from the collection 'userdetails' the following mongodb
command can be used :

>db.userdetails.remove({})
If we want to remove the entire 'userdetails' collection, including all of its documents the
following mongodb command can be used :

>db.userdetails.drop()

Output:

> db.userdetails.drop();
true

The drop() returns either true or false. The above function returns true, it means that the
operation has completed successfully.

If we want to remove an entire database the following mongodb command can be used:
>db.dropDatabase();

{ "dropped" : "myinfo", "ok" : 1 }

6
 CREATING DATABASE “UEFAChampionsLeague”

 CREATING COLLECTION “Group A Players Info”

7
 INSERTING DOCUMENTS of each player having fields as
“_id”,
“first_name”,
“last_name”,
“nominal_position”,
“nationality”,
“date_of_birth”,
“fc_name”,
“goals”,
“assists”,
“penalty_cards”

8
9
 VIEWING AS TABLES

10
11
Software used: MongoDB – Compass

12
Conclusion

During the course of this project, we learnt a lot of the work and best practices that go into
creating a database in MongoDB, the rules to construct collections and input of documents,
how to come up with clusters and connecting MongoDB Compass with MongoDB Atlas. We
learnt on how to design a system from Database perspective and how to efficiently store and
manipulate data.

13

You might also like