Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Asnswer 2 0 questions using NoSQL and this database in the picture: Q 1 : Find the total number of orders placed by each customer.

Asnswer 20 questions using NoSQL and this database in the picture:
Q1: Find the total number of orders placed by each customer.
// Q2: List all customers who have placed more than 2 orders.
// Q3: Find the total sales amount for each sales representative.
// Q4: List all products with a price greater than $200.
// Q5: Find the average price of products in each category.
// Q6: Count the number of products that have stock quantity less than 50.
// Q7: Find all orders with a total amount greater than $300.
// Q8: List all suppliers located in the USA.
// Q9: Find the maximum price of any product.
// Q10: List all products supplied by 'Office World'.
// Q11: Count the number of distinct categories of products.
// Q13: List all orders along with the products ordered in each.
// Q14: Find the total quantity of 'Keyboard' sold.
// Q16: List all products ordered by each customer.
// Q17: Find the total revenue generated by each product category.
// Q18: Find the total number of orders with status 'Shipped'.
// Q19: Find the products that have been ordered more than 5 times.
// Q20: Find the average quantity ordered for each product. // Create Customers collection
db.Customers.insertMany([
Country: 'USA', SalesRepID: 2},
SalesRepID: 1},
'Canada', SalesRepID: 3},
'Canada', SalesRepID: 2},
SalesRepID: 1},
'Canada', SalesRepID: 3},
'USA', SalesRepID: 2},
Country: 'USA', SalesRepID: 1},
'Canada', SalesRepID: 3},
'USA', SalesRepID: 2}
]); db.Orders.insertMany([{ OrderID: 2, CustomerID: 5, OrderDate: new Date('2024-06-02'), Status: 'Pending', ShippingDate: null, TotalAmount: 200.00, SalesRepID: 2},{ OrderID: 4, CustomerID: 2, OrderDate: new Date('2024-06-04'), Status: 'Cancelled', ShippingDate: null, TotalAmount: 100.00, SalesRepID: 2},{ OrderID: 6, CustomerID: 4, OrderDate: new Date('2024-06-06'), Status: 'Shipped', ShippingDate: new Date('2024-06-12'), TotalAmount: 400.00, SalesRepID: 3},{ OrderID: 8, CustomerID: 6, OrderDate: new Date('2024-06-08'), Status: 'Delivered', ShippingDate: new Date('2024-06-13'), TotalAmount: 450.00, SalesRepID: 2},]);// Create Products collection
db.Products.insertMany([{ ProductID: 2, ProductName: 'Keyboard', Category: 'Accessories', StockQuantity: 300, Price: 29.99},{ ProductID: 4, ProductName: 'Desk', Category: 'Furniture', StockQuantity: 40, Price: 399.99},{ ProductID: 6, ProductName: 'Headphones', Category: 'Electronics', StockQuantity: 200, Price: 89.99},{ ProductID: 8, ProductName: 'Printer', Category: 'Office Supplies', StockQuantity: 60, Price: 149.99},{ ProductID: 10, ProductName: 'Laptop', Category: 'Electronics', StockQuantity: 50, Price: 999.99}
]); db.OrderDetails.insertMany([{ OrderDetailID: 2, OrderID: 2, ProductID: 6, Quantity: 4, UnitPrice: 199.99},{ OrderDetailID: 4, OrderID: 4, ProductID: 9, Quantity: 3, UnitPrice: 19.99},{ OrderDetailID: 6, OrderID: 6, ProductID: 7, Quantity: 1, UnitPrice: 499.99},{ OrderDetailID: 8, OrderID: 8, ProductID: 3, Quantity: 1, UnitPrice: 99.99},]);// Create Suppliers collection
db.Suppliers.insertMany([{ SupplierID: 2, SupplierName: 'Office World', ContactName: 'Jane Smith', ContactEmail: 'jane.smith@officeworld.com', Phone: '234-567-8901', Country: 'USA' },]);// Create ProductSuppliers collection
db.ProductSuppliers.insertMany([{ ProductID: 2, SupplierID: 2},{ ProductID: 4, SupplierID: 3},{ ProductID: 6, SupplierID: 4},{ ProductID: 8, SupplierID: 2},{ ProductID: 10, SupplierID: 1}
]);
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions