Department of Electrical and Information Engineering
Faculty of Engineering, University of Ruhuna
EE4202: DATABASE SYSTEMS - NoSQL ASSIGNMENT
Task
Create a NoSQL database (document database) using MongoDB to store student
(collection) data. The sample document format is given in figure 01. The student collection
should contain 20 documents. Then write queries and complete the following tasks.
1. Insert 20 documents into the student collection
2. Retrieve the first document (should contain your data. i.e. name and reg_no)
3. Retrieve specific documents from the collection by _id
4. Retrieve students whose specialization is ‘Software’
5. Retrieve students whose city is ‘Gampaha’
6. Retrieve student whose specialization is ‘Software’ and gender is ‘F’
7. Retrieve only the reg_no of all students
8. Retrieve only first name, last name and specialization of all students
9. Retrieve only reg_no and address of who was born after 2000
10. Retrieve only the first name and modules of those who were born on or before 2000
11. Count the number of students who got an ‘A’ for ‘EE1202’
12. Count the number of students who got ‘B’ or ‘C’ for ‘EE2302’
13. Retrieve only reg_no of the students who have failed (‘F’) at least two modules
14. Delete all students who have failed (‘F’) at least two modules and get the count of
the remaining students
15. Update all the documents by adding a new field {status: ‘passed’} and
show the result.
16. Update your specialization (i.e first document) to a different field.
Department of Electrical and Information Engineering Faculty of Engineering, University of Ruhuna
{
name: {first:‘Supun’,middle:‘Kumara’,last:‘Perera’},
reg_no: ‘EG/xxxx/xxxx’,
gender:‘M’,
yearOfBirth:1999,
address: {no:‘20/2’, town:‘Hapugala’, city:‘Galle’},
specialization: ‘Electrical’,
modules:[
{code: ‘EE1202’,grade: ‘A’},
{code: ‘EE2301’,grade: ‘C’},
{code: ‘EE2302’,grade: ‘B’},
{code: ‘EE3202’,grade: ‘C’}
]
}
Figure 01: Sample document
Note: You can add data members to the document given in figure 01 if required. But
you cannot remove any given data members.
Guidelines
● Install the MongoDB latest version to your PC and implement the given task only
using CLI (Command Line Interface) or shell.
● Do not use any GUI applications (ex: MongoDB Compass) to complete this
assignment.
● Take screenshots of each step including the installation and initialization steps
● The first document of the student collection should contain your details. (Only name
and register number are sufficient. Other fields can have dummy data).
● Other 19 documents can have dummy data
Submission
Make a report containing the approaches to completing each task with screenshots of
steps and results.
Submit the report (max. 20 pages PDF) to the given link in the LMS before the deadline.
Deadline: 19th Nov 2022 (Late submissions will not be accepted)
Department of Electrical and Information Engineering Faculty of Engineering, University of Ruhuna