RMIT
Database Applications ISYS1101/1102
2 Assessment Details
2.1 Preparation Work
1. 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;
2. 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.
2.2 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.
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.
a. Display 3-bedroom apartments in Barcelona.
b. Display listings in Barcelona that has both Wifi and Cable TV.
c. Compute and display the average daily rate for Barcelona properties.
d. Display the average price for 3-bedroom apartments in Barcelona.
e. 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.
f. Display 10 “least-expensive” tourist destinations for travelers. The “least expensive” is
determined by averaging the prices of all properties in each destination.
2. 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.
3. 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.
4. 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.
5. 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:
1. 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.
2. 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.
a. Add the first booking in the sample bookings file to your extended database.
b. 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.
咨询 Alpha 小助手,获取更多课业帮助