Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction This week you will be designing the database for the Food Order App in MongoDb. You will create collections, insert documents and retrieve records
Introduction
This week you will be designing the database for the Food Order App in MongoDb. You will create
collections, insert documents and retrieve records from the database.
All the create and insert operations in the database should be performed by executing the script.js file
given in ScriptToPopulateDatabase folder.
All the select operations should be performed using the Mongo Shell. You can also use the MONGOSH
shell attached to MongoDB Compass at the bottom
Problem Statement
Your task is as follows
Create Database and Collections
Create a database named FoodOrderAppDb in your MongoDB Compassusing localhost
connection or MongoDb Atlas cloud account.
Create users, userSessions, categories, cuisines, restaurants, food items, menus,
menuitems, carts, cartitems, shippingDetails, orders and orderitems collections.
Further, we need to insert data in the collections. We have already created a script using
mongoose library to create various schemas and models. Also, we have added code to
insert in these collections. For creating collections and inserting documents kindly follow
the steps given below:
Make sure that NodeJS is installed on the system.
Open the ScriptToPopulateDatabase folder in VSCode.
Open the terminal.
First run the command npm install to install nodemodules and all the
dependencies.for example, mongoose library
Next, put your MongoDB Connection String in the mongoose.connect
method.
Finally, run the command node script.js to create all the collections and
insert documents in these collections from the json files present in the data
folder.
You can go to MongoDB Compass or MongoDB Atlas to see if the collections
are created with documents inserted in them.
Now you can take screenshots of documents entered in each collection and
paste in the respective placeholders provided in the NoSQL AssessmentFor
Noncoders.docx file provided.
Retrieve records
Retrieve the following records
i All distinct category names
ii All vegetarian fooditems
iii. Retrieve the name and address of each of the restaurants.
iv All orders with orderTotalPrice within the range of $ to $
v All orders which were created after th May
vi All fooditems belonging to Italian cuisine.
vii. Get the userName and email of the user with fullname "John Doe".
viii. Retrieve details of the order with the lowest orderTotalPrice.
ix Get the count of menu items for fooditem Veg Pizza
x Get the count of orders for each restaurant
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started