

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A mongodb database design with four collections: employees, product, inventory, and sales. It includes creating tables, inserting sample data, and updating inventory quantity. This design can be used for managing customer orders and product inventory.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CREATE TABLE Employees ( EmployeeID varchar(255), Employee_Name varchar(255), Address varchar(255) ); CREATE TABLE Product ( ProductID varchar(255), Model varchar(255), Price varchar (255) ); CREATE TABLE Inventory ( InventoryID varchar(255), ProductID varchar(255), Quantity int ); INSERT Customer (CustomerID, Customer_Name, Address) VALUES ('1', ‘Esme’, ‘asdf, asdff); INSERT Product (ProductID, Model, Price) VALUES ('112', 'iPhone-X', CAST(45000.00 AS Decimal(18, 2))); INSERT Sales (SalesID, CustomerID, ProductID, PurchaseDate, SQuantity) VALUES ('S-1', 'C-1', 'P-1', CAST(N'2021-07-21' AS Date), 2); INSERT Inventory (InventoryID, ProductID, Quantity) VALUES ('I-1','P- 1', 49); UPDATE Inventory SET quantity = (Inventory.quantity - Sales.squantity) FROM Sales db.createCollection("Customer") db.Customer.insertOne({_id: "C-1", CustomerName: "Rosalie", Address: "asdf"}) db.createCollection("Product") db.Product.insertOne({_id:"P-1", Model: "iPhone-X", Price: 45000.00}) db.createCollection("Sales") db.Sales.insertOne({_id: "S-1", CustomerID: "C-1", ProductID: "P-1", PurchaseDate:ISODate("2021-07-21T08:00:00.000"), SQuantity: 2}) db.createCollection("Inventory") db.Inventory.insertOne({_id:"I-1",ProductID: "P-1", Quantity: 49, })
db.Inventory.updateOne({_id: "I-1"}, {$set:{Quantity: 47}})