/status-report

A command-line application for managing a company's employees using Node, Inquirer, and MySQL. The app allows users to add/view/update/delete departments, roles and employees from the database.

Primary LanguageJavaScript

Status Report

M.I.T. License use

Description

A simple command-line-application that utilizes MySQL, Node, and the Inquirer package.

View the application here

Table of Contents

Technologies Used

  • Node
  • Express
  • Inquirer
  • MySQL

Goals

  1. To create a command-line application that allows users to:

    • Add departments, roles, employees

    • View departments, roles, employees

    • Update employee roles

  2. Use the following tools and technologies:

    • MySQL NPM package to connect to your MySQL database and perform queries.

    • InquirerJs NPM package to interact with the user via the command-line (collect user input).

    • console.table to print MySQL rows to the console. There is a built-in version of console.table, but the NPM package formats the data a little better for our purposes.

    • (Optional) You may wish to have a separate file containing functions for performing specific SQL queries you'll need to use. Could a constructor function or a class be helpful for organizing these?

    • To perform a variety of SQL JOINS to complete this assignment - review class activities as needed.

  1. Focus on getting the basic functionality completed before working on more advanced features.

  2. (Recommended) Include a seed.sql file to pre-populate your database. This will make development of individual features much easier.

  3. Use Screencastify and provide a link to a walkthrough video that demonstrates its functionality.

Definitions

The goals above and the application can be further understood with the following definitions:

node.js : an implementation of the V8 JavaScript engine without Chrome. It allows you to write server-side code using JavaScript. This means that you no longer need a browser to run JavaScript. You can do so from the command line. Node.js ships with a standard library.

database : a collection of data stored electronically.

DBMS : the database management system (i.e. MySQL)

MySQL : the most popular SQL database with a relational structure.

SQL database : Structured Query Language

relational database : stores and finds data based on its relationship to other data in the database. Relational databases are tabular, meaning that data is stored in tables composed of rows and columns, much like a spreadsheet.

schema.sql : a file that uses .sql database and used to write MySQL tables.

CRUD : functions that Create Render Update Delete.

Joins : command that joins two or more tables and the specified data and combines the data

inquirer : an npm package that provides an easy way to capture user input in your node.js command-line interface applications. It provides several methods for asking questions and returning answers from the user that can be accessed by a .then promise function.

Instructions

Design the following database schema containing three tables:

schema-demo

  • department:

    • id - INT PRIMARY KEY
    • name - VARCHAR(30) to hold department name
  • role:

    • id - INT PRIMARY KEY
    • title - VARCHAR(30) to hold role title
    • salary - DECIMAL to hold role salary
    • department_id - INT to hold reference to department role belongs to
  • employee:

    • id - INT PRIMARY KEY
    • first_name - VARCHAR(30) to hold employee first name
    • last_name - VARCHAR(30) to hold employee last name
    • role_id - INT to hold reference to role employee has
    • manager_id - INT to hold reference to another employee that manages the employee being Created. This field may be null if the employee has no manager

Build a command-line application that at a minimum allows the user to:

  • Add departments, roles, employees

  • View departments, roles, employees

  • Update employee roles

Bonus points if you're able to:

  • Update employee managers

  • View employees by manager

  • Delete departments, roles, and employees

  • View the total utilized budget of a department -- ie the combined salaries of all employees in that department

User Story

As a business owner
I want to be able to view and manage the departments, roles, and employees in my company
So that I can organize and plan my business

Acceptance Criteria

The application must meet the following requirements:

GIVEN a command-line application that accepts user input
WHEN I am prompted to add a department, role, or employee
THEN I am able to add a department, role, or employee
WHEN I view the departments, roles, and employees
THEN this is displayed within a table -----
WHEN I update an employee's role
THEN this information is added to the employee's information

Installation

-------Steps required to create Employee Tables:

  1. Create a new repository.

    • Open GitHub and create new repository.
    • do NOT add a README.md file upon creation (that would defeat the purpose!).
  2. Create a new directory to house new repo on your local computer.

    • Open Terminal (if MacOS), create a new directory using mkdir project-name
    • Make sure you are in the root file of your local repository before you create any files.
  3. Clone your GitHub repository to your local computer (make sure you are in the root folder of your new directory)

    git clone ssh-key-from-repository
    
  4. Create a .gitignore file:

    • type node_modules in first line
    • type .DS_Store in second line
  5. Create a new package.json file:

    • Initialize npm: npm init. This will be used to set up a new or existing npm package. You can customize the fields, or you can continue to press the enter key until you see 0 vulnerabilities.
    • This will create a package.json file and a package-lock.json file.
    • Install the Inquirer package using: npm install inquirer
    • This will create a node_modules file.
    • You are now ready to create your index.js file: touch server.js
  6. Set up Inquirer package within your newly created server.js file.

const inquirer = require('inquirer');
const fs = require("fs");
const util = require("util");
  1. Copy and paste the code (or fork it) from the server.js within this repository.

  2. Save file. Run server.js file within terminal using node server.js

  3. If working, answer the prompts by entering your own inputs via the command line.

Usage

Enter your inputs via the command-line:

view of terminal prompts

view of terminal prompts

Credits

Reference articles:

Contact

Dana Smooke

Bugs

** Update: March 2021 Some functions of the application are not yet finished. **

License

MIT


© 2020 Trilogy Education Services, LLC, a 2U, Inc. brand. Confidential and Proprietary. All Rights Reserved.