In this assignment, a command line interface (CLI) node app was created which closely resembles Amazon Market Place . This app will take in orders from customers and adjust stock from the store's inventory. Additionally, the app tracks product sales across your store's departments and then provide a summary of the highest-grossing departments in the store.
You can find the instructions for this assignment here: homework-instructions.md
Since this is a basic app, the items in to store are predefined with 10 items. The overall goal of this assignment was using node with a sql interface to process data.
- Node.JS
runtime
- MySQL
database
npm-package
- Inquirer
npm-package
- cli-table
npm-package
- dot-env
npm-package
- Customer view
- Purchase item
- Manager view
- View all products
- View low inventory
- Add more of inventory
- Add new product
- Supervisor view
- View Products Sales by Department
- View All Departments
- Create New Department
- Remove Department
For the database design, since we include customer, manager, and supervisor views, multiple tables are related. The products
table references the departments
table by department_id
. A foreign key
is added to secure the relationship.
CREATE TABLE products ( ... );
CREATE TABLE departments ( ... );
ALTER TABLE products
ADD FOREIGN KEY (department_id) REFERENCES departments(department_id);
-
Calling a complex query with the Supervisor view we a challenge. There were multiple operations in the query command and any syntax errors, MySQL doesn't provide the best detail. Ultimately, my
GROUP BY
was missingdeaprtments
which was important.SELECT departments.department_id, department_name, over_head_costs, SUM(product_sales) AS 'product_sales', (SUM(products.product_sales) - departments.over_head_costs) AS 'total_profit' FROM departments INNER JOIN products ON departments.department_id = products.department_id GROUP BY department_name, departments.department_id, departments.over_head_costs ORDER BY department_name;