Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MongoDB is an open - source document - oriented database that is designed to store large scale data. It is categorised as a NoSQL (
MongoDB is an opensource documentoriented database that is designed to store large scale data. It is categorised as a NoSQL Not only SQL database because the storage and retrieval of data in the MongoDB is not in the form of tables and querying does not have to be done using SQL
Based on this document database, write queries in MongoDB for each of the following tasks.
a Display the customer id and customer name of all customers with a balance of $ and who are not from Christchurch sorted by customer id
b Display the customer id customer name, customer city and customer balance of all customers sorted by customer name in ascending order.
c Display the product name and product price for every product in the system. Sort the results by product name. Duplicates should be removed.
dDisplay the product name and total for all orders made by customer number sorted by total in descending order.
e Display the product name and product price for all products that cost greater than or equal to $
f For each customer, display the customers name, the number of order and the order total.
g Display the number of distinct products in the system.
h Display the product name and the product price for the product with highest price.
i Display the customer name for all customers who have never ordered a product.
jDisplay all cities customers are based in and the number of customers in each city.
k Display the product name and total for all the products ordered by John
l Display the product name and the number of times each product has been ordered.
m Insert a new customer, HansDunedin
n Insert a new order for Hans, Wenlock and update the customer balance for Hans to
id:
$oid": ebade
"custid:
"custname": "John",
"custcity": "Christchurch",
"custbalance":
"orders":
"prodname": "Albertine",
"prodprice":
"prodqty:
"total":
"prodname": "Amelia",
"prodprice":
"prodqty:
"total":
"prodname": "Allotria",
"prodprice":
"prodqty:
"total":
id:
$oid": fbadea
"custid:
"custname": "Hannah",
"custcity": "Christchurch",
"custbalance":
"orders":
"prodname": "Ausblush",
"prodprice":
"prodqty:
"total":
"prodname": "Ausbord",
"prodprice":
"prodqty:
"total":
id:
$oid": fbbadeb
"custid:
"custname": "Rita",
"custcity": "Christchurch",
"custbalance":
"orders":
"prodname": "Ausmas",
"prodprice":
"prodqty:
"total":
"prodname": "Chaucer",
"prodprice":
"prodqty:
"total":
id:
$oid": cebadec
"custid:
"custname": "Milly",
"custcity": "Wellington",
"custbalance":
"orders":
"prodname": "Leander",
"prodprice":
"prodqty:
"total":
"prodname": "Lucetta",
"prodprice":
"prodqty:
"total":
"prodname": "Chianti",
"prodprice":
"prodqty:
"total":
"prodname": "Perditta",
"prodprice":
"prodqty:
"total":
id:
$oid": dabaded
"custid:
"custname": "Angela",
"custcity": "Auckland",
"custbalance":
"orders":
"prodname": "Chianti",
"prodprice":
"prodqty:
"total":
"prodname": "Chaucer",
"prodprice":
"prodqty:
"total":
"prodname": "Leander",
"prodprice":
"prodqty:
"total":
id:
$oid": dabadee
"custid:
"custname": "Barbara",
"custcity": "Dunedin",
"custbalance":
"orders":
id:
$oid": dbadef
"custid:
"custname": "Bradley",
"custcity": "Christchurch",
"custbalance":
"orders":
"prodname": "Chaucer",
"prodprice":
"prodqty:
"total":
"prodname": "Perditta",
"prodprice":
"prodqty:
"total":
"prodname": "Prospero",
"prodprice":
"prodqty:
"total":
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