Database Applications ISYS1101/1102 | Semester 2 2024
Assignment 2: MongoDB
Changelog:
A minor correction was made to Task 1, Question (e):
Old: Display the listings within a $10-range from the average price you found in Part (e). i.e. New: Display the listings within a $10-range from the average price you found in Part (d). i.e.
Assessment Type |
MongoDB Database Design, Implementation, Queries, and Demonstration Individual Assessment |
Due Date |
23:59 Sunday 13 October 2024 |
Demonstrations |
Week starting Monday 14 October 2024 |
Silence Period |
Starts at 5:00PM Friday 11 October 2024 |
Weight |
25% |
Submission |
Online, via Canvas. Submission instructions are provided on Canvas. |
-
Overview
-
Assessment Criteria
This assessment will determine your ability to:
-
analyse the requirements outlined in the problem description;
-
write MongoDB queries required for CRUD (create, read, update and delete) operations on the AirBnB database available on MongoDB Atlas;
-
expand the AirBnB database with additional document collections to accommodate bookings;
-
write MongoDB queries to manage bookings;
-
be able to demonstrate the functionality of your database and answer questions posed by the marker
-
-
Learning Outcomes
This assessment will assess how you attained the following course learning outcomes:
CLO 1: apply advanced data analysis and modeling concepts, physical design, integrity, security and transaction management.
CLO 4: build an efficient database application with an emphasis on storage management, indexing, and query optimization;
CLO 5: use MongoDB for store and retrieve non-relational data;
-
-
Assessment Details
-
Preparation Work
-
You must have deployed your MongoDB database on MongoDB Atlas, the cloud-based MongoDB database platform (cloud.mongodb.com). You must have populated your database with the sample database called “sample_airbnb” with “listingsAndReviews” documents collection;
-
You are required to have the Mongo Compass client application installed on your laptop, having it properly configured to access your MongoDB database running on MongoDB Atlas (see above);
Week 9 labsheet walks you through, in step-by-step detail, on how to set up MongoDB Atlas and MongoCompass. If you haven’t completed Week 9 lab, you must complete it before attempting the assignment tasks outlined below. Apart from Week 9 Lab, no further instructional support provided for setting up your database environment at this stage, however, you can use regular consultation sessions to get any teething issues resolved.
You must be very familiar with the document structure of the listingsAndReviews document collection, able to write simple queries on this document collection and be able to build aggregation pipelines on it. You can acquire these skills by completing Labsheets 9 – 11.
-
-
Assignment Task Description
-
Milestone 1: Written Submission
Task 1: CRUD tasks on listingsAndReviews Document Collection
In this task, you are required to provide statements written in MongoDB Query Language. Some of the statements can be written as a simple query, while some of them require a multi-stage aggregation pipeline. Importantly, you must provide your answers in two formats: (1) in Mongo Shell format; and (2) as inputs into Mongo Compass.
Sample Question: Display listings with a daily rent (price) of $50.00
You will try it out on both interactive Compass window and Mongo Shell
Sample Answer to be submitted:
Mongo Shell: db.listingsAndReviews.find ( {price : 50} )
Do not submit any screenshots of Mongo Compass, only statements in plain text are to be submitted.
Write MongoDB statements to extract data on each of the following filtering conditions. For the questions below, use the ‘market’ sub-field of the Address field. In the tourism industry, it is a commonly used term to determine specific tourist destinations.
-
Display 3-bedroom apartments in Barcelona.
-
Display listings in Barcelona that has both Wifi and Cable TV.
-
Compute and display the average daily rate for Barcelona properties.
-
Display the average price for 3-bedroom apartments in Barcelona.
-
Display the listings within a $10-range from the average price you found in Part (d)(
e).i.e. 3-bedroom apartments in Barcelona with price in the range [avgPrice – 5 avgPrice
+ 5].
-
Display 10 “least-expensive” tourist destinations for travelers. The “least expensive” is determined by averaging the prices of all properties in each destination.
-
The owner of the listing named “Be Happy in Porto” wishes to add “Netflix” as a new amenity. Write a MongoDB statement to add this new amenity into the amenities list of the existing listing.
-
A recent guest to the listing named “Be Happy in Porto” wishes to add the following comment as a guest review:
“This holiday accommodation did not meet my expectation. Being in Portugal, I wanted to watch bull-fighting from the balcony. But, neither balcony nor bull-fighting nearby are there.”
Write a MongoDB statement to add this comment into the reviews array of the existing listing of this property. Your new review must be of the same structure as any existing review.
-
The current daily rate for the listing named “Be Happy in Porto” is $30.00. Fabio, the owner, computes the average daily rate of similar properties in the area. For similarity comparison, he uses the property type and the number of bedrooms of the properties in the same market, i.e. he only considers the properties that are same type as his property and also having the same number of rooms as his. Then, he decides to set his property’s daily rate 10% lower than the average daily rate.
Write a MongoDB statement to change the daily rate of the afore-mentioned listing.
-
Fabio, the owner of the above-mentioned listing, didn’t like the recent review given by the guest mentioned in the question 3. He wants to delete this feedback.
Write a MongoDB statement to delete the feedback currently stored in the reviews array.
Task 2: Extend the AirBnB database
The current sample database consists of only one document collection, which comprises of information on listings and reviews. It is built on “embedded” data model, where each document outlines information on listings and for each listing, additional information such as user reviews and hosts’ details are “embedded”.
In this task, you are required to extend the database to allow taking bookings of listings. The specifications for the extended system is outlined below.
For simplicity, assume that listings can only be booked for whole days, and no hourly bookings are accepted. At the moment, listings can be booked into the future, as far as 31 December 2026.
Bookings are made by registered clients of the AirBnB system. Each client has a unique client_ID generated by the system. In addition, they use an email address for login.
Bookings are for individual listings, i.e. you cannot book multiple listings in a single booking. Each booking is for a specific period, defined by the arrival date and departure date.
In addition to the listing name, arrival and departure dates, each booking will capture the identification details of the client, such as name, email address, daytime phone number, mobile number, postal address and home address. The other information included in a booking are: the deposit paid at the booking, the balance due, the due date for the balance payment, and number of guests, and for each guest the names and their ages. These other guests are not required to be registered clients of the AirBnB system.
Your tasks:
-
Under embedded and referenced approaches, using two examples, demonstrate how these additional requirements are accommodated in an extended version of this database.
You must identify in your model, the additional collections or fields required and state whether your new information are “embedded” within the current collection (listingsAndReviews) or build as separate collections using “reference” approach.
As sample data, you may use the new bookings data found in a text file attached to the assignment folder.
-
Provide Mongo Shell statements, written in MongoDB Query Language, to carry out the tasks listed below. Some of the statements can be written as a simple query, while some of them may require a multi-stage aggregation pipeline. Importantly, you must provide queries for the both models you proposed in the answer for above question.
-
Add the first booking in the sample bookings file to your extended database.
-
Display the client name, email address, booking start date, and booking end date for all bookings made so far for the listing named “Be Happy in Porto”.
-
Do not submit any screenshots of Mongo Compass, only statements in plain text are to be submitted.
The answers to the questions in Task 1 and Task 2 must be compiled into a single pdf document. You may use a plain text file or a word document to compile the answers, however, the final submission must be in pdf format. Only one file must be submitted.
Milestone 2: Demonstrate your work.
You are required to do a demo of your complete application hosted on MongoDB Atlas. These demos will be conducted during the week of 14th October. You should have some booking data
stored in the application and the tutor will test out the functionality by using a test bed of data.
Tutors will use a standard testing plan for all submissions and you will only receive your Task 1 and Task 2 marks if you can demonstrate the functionality of your application during the demo.
Reviews
There are no reviews yet.