/Employee-Tracker

A command-line application to manage a company's employee database, using Node.js, Inquirer, and MySQL

Primary LanguageJavaScriptMIT LicenseMIT

Employee-Tracker

License: MIT

Employee Tracker is a command-line application to manage a company's employee database. With this application, you will be able to view and update 3 SQL tables (department, role, and employee). The purpose of this application is to have a Content Management System so that non-developers can easily view and interact with information stored in databases. The application uses Node.js, Inquirer, and MySQL.

GIF of Application


Table of Contents


Getting Started

To begin the application, use the following in command line:

node server.js

Prerequisites

  1. Download Node.js

  1. Install node package manager (npm)

npm install -g npm


  1. Install dependencies inquirer, console.table, and mysql2

npm install


  1. Download mysql

Technologies Used


Screenshots


Screenshot of Initial Prompt



Screenshot of View Employees table



Screenshot of Add Department prompt



Screenshot of Add Role prompt



Screenshot of Add Employee prompt



Screenshot of Update Employee prompt



Code Snippets

This code snippet shows how you can use SQL and npm mysql2 to create a function to view the departments table

  • const sql uses Structured Query Language SELECT statement to display columns with an alias FROM the department table

  • ".query" is a built-in method in npm mysql2 to execute a query in the mysql database

  • "console.table()" method displays tabular data as a table

function viewDepartments() {
  const sql =
    "SELECT department.id AS id, department.name AS department FROM department;";

  db.query(sql, (err, data) => {
    if (err) {
      console.log(err);
    }
    console.table(data);
    initPrompt();
  });
}

Learning Points

  • How to use npm mysql2 to generate MySQL queries

  • How to use promises and switch statements

  • How to use SQL statements (SELECT, INSERT, DELETE, UPDATE, JOIN)

  • How to use MySQL Workbench as a MySQL graphical user interface


Author

1. Elliot Park

Github


LinkedIn


Email