Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
ISYS1101/ 1102 Database Applications
Week 7: Tute/Lab – Getting Started with MongoDB
1 Objective
The objective of this tute/lab session is to explore the features of MongoDB, learn how to build a
document collection and retrieve data from a collection, and how to build a web database
application with MongoDB backend.
NoSQL databases, such as MongoDBÒ (mongodb.com), were created in response to the
limitations of traditional relational database technology. When compared against relational
databases, NoSQL databases are more scalable and provide superior performance, and their data
model addresses several shortcomings of the relational model.
The advantages of NoSQL include being able to handle:
• First and foremost, it is very easy to install and setup the MongoDB.
• The very basic feature of MongoDB is that it is a schema-less database. Since MongoDB is
schema-free, your code defines your schema.
• Large volumes of structured, semi-structured, and unstructured data;
• Agile development;
• Inherently secure because no sql injection can be made.
• Compared to RDBMS, NOSQL database systems are light-weight, very little overheads,
and, has a smaller memory footprint and as a result, provide a far superior performance.
• Horizontal scaling (sharding) – The support for Sharding is one of its key features. Sharding
is the process of storing the data in different machines and MongoDB’s ability to process
the data, as and when the size of the data grows. This results in the horizontal scaling.
• Replication — Auto data replication is also supported in NoSQL databases by default.
Hence, if one DB server goes down, data is restored using its copy created on another
server in network.
Science of Science/ Computer Science and IT
Document: Week 7 – Getting Started with MongoDB.docx
Author: Santha Sumanasekara
Today, companies leverage NoSQL databases for a growing number of use cases. NoSQL
databases also tend to be open-source and that means a relatively low-cost way of developing,
implementing and sharing software.
Companies choose MongoDB for developing modern applications as it offers the advantages of
relational databases along with the innovations of NoSQL.
In the second half of the Database Application course, we explore the features of MongoDB, learn
how to build a document collection and retrieve data from a collection, and how to build a web
database application with MongoDB backend.
In the second assignment you will rebuild Facebook-Lite application you worked out in Assignment
1 using MongoDB backend. The activities in this tute/lab session will assist you to learn the basics
required to start your assignment work.
2 Preparation Tasks
MongoDB is not available on School’s servers or on mydesktop.rmit.edu.au. As outlined on the
course guide, you are required to install it on your personal computer (ideally, a mac, Linux or 64-
bit Windows).
If you do have prior experience in system administration and/or compiling and
installing new applications on your computer, you may choose to do your own
installation. However, if you choose to follow your own approach, we cannot help with
any troubleshooting with your setup.
To make your installation simple, platform-independent, and trouble-free, we use the Docker
(docker.com) platform. The MongoDB database server and a pre-configured web server are
installed as Docker containers. The client applications (MongoDB Compass and a web browser)
will run as native applications on your host computer.
Docker is a tool designed to make it easier to create, deploy, and run applications by using
containers. Containers allow a developer to package up an application with all of the parts it needs,
such as libraries and other dependencies, and ship it all out as one package.
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a
whole virtual operating system, Docker allows applications to use the host computer as the system
that they’re running on and only requires applications be shipped with things not already running
on the host computer. This gives a significant performance boost and reduces the size of the
application.
Another major advantage is that these containers are platform-independent and will work
anywhere that you can install (and run) Docker application.
For this part of the course we use two Docker containers – a MongoDB database container and a
customised Nginx web server container with php and MongoDB module for php. They are
organised as follows:
Science of Science/ Computer Science and IT
Document: Week 7 – Getting Started with MongoDB.docx
Author: Santha Sumanasekara
Save Date: 05/09/2019
Page 3 of 10
2.1 Installing Docker Desktop
In order to run applications within docker containers, you must have the Docker Desktop installed
on your host computer. This application is available for 64-bit Windows, Linux and Mac. Download
it from hub.docker.com and install it.
You will be required to create a “free” account on Docker Hub. Docker Hub has thousands of prebuilt docker containers, as well.
On some rare instances (we have found some Microsoft Surface laptops experience this problem),
some laptops require changes to BIOS settings enabled to run virtualisation software, like Docker
Desktop.
If you get an error message – “This computer doesn’t have VT-X/AMD-v enabled. Enabling it in the
BIOS is mandatory” – You may have to follow the instructions given on the above webpage.
If you encounter this (rare) problem, your Lab assistant will show you how to tweak
BIOS settings.