A simple command-line-application that utilizes MySQL, Node, and the Inquirer package.
View the application here
- Technologies Used
- Goals
- Definitions
- Instructions
- User Story
- Acceptance Criteria
- Installation
- Video
- Usage
- Credits
- Contact
- Bugs
- License
- Node
- Express
- Inquirer
- MySQL
-
To create a command-line application that allows users to:
-
Add departments, roles, employees
-
View departments, roles, employees
-
Update employee roles
-
-
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.
-
-
Focus on getting the basic functionality completed before working on more advanced features.
-
(Recommended) Include a
seed.sql
file to pre-populate your database. This will make development of individual features much easier. -
Use Screencastify and provide a link to a walkthrough video that demonstrates its functionality.
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.
Design the following database schema containing three tables:
-
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
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
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
-------Steps required to create Employee Tables:
-
Create a new repository.
- Open GitHub and create new repository.
- do NOT add a README.md file upon creation (that would defeat the purpose!).
-
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.
- Open Terminal (if MacOS), create a new directory using
-
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
-
Create a .gitignore file:
- type
node_modules
in first line - type
.DS_Store
in second line
- type
-
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 see0 vulnerabilities
. - This will create a
package.json
file and apackage-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
- Initialize
-
Set up Inquirer package within your newly created
server.js
file.
const inquirer = require('inquirer');
const fs = require("fs");
const util = require("util");
-
Copy and paste the code (or fork it) from the
server.js
within this repository. -
Save file. Run
server.js
file within terminal usingnode server.js
-
If working, answer the prompts by entering your own inputs via the command line.
Enter your inputs via the command-line:
Reference articles:
Dana Smooke
** Update: March 2021 Some functions of the application are not yet finished. **
© 2020 Trilogy Education Services, LLC, a 2U, Inc. brand. Confidential and Proprietary. All Rights Reserved.