MongoDB Database Design: Employees, Product, Inventory, and Sales, Exercises of Information Systems

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

2020/2021

Uploaded on 05/23/2021

darnieloie
darnieloie 🇵🇭

4

(1)

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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, })
pf2

Partial preview of the text

Download MongoDB Database Design: Employees, Product, Inventory, and Sales and more Exercises Information Systems in PDF only on Docsity!

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}})