Objective: Mongodb Is An Open-Source Database Written in C++. Development of Mongodb Began in
Objective: Mongodb Is An Open-Source Database Written in C++. Development of Mongodb Began in
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?
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.
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 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 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.
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:
switch to db myinfo
{
"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.
> db.userdetails.insert(document)
> 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"]});
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();
6
CREATING DATABASE “UEFAChampionsLeague”
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