Skip to content

oraclepool/sql-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

9 SQL Challenge

This repository contains the following scenario:

Employee Database: A Mystery in Two Parts

In this repository, the major task is a research project on employees of a corporation from the 1980s and 1990s. All that remain of the database of employees from that period are six CSV files.

We will design the tables to hold data in the CSVs, import the CSVs into a SQL database (Postgres), and answer questions about the data. The two major tasks are:

  1. Data Engineering / Data Modeling

  2. Data Analysis

Data Modeling

Inspect the CSVs and sketch out an ERD of the tables. We use the Quick Database Diagrams.

ERD.png

Data Engineering

  • Create a table schema for each of the six CSV files.

    • For the primary keys check to see if the column is unique, otherwise create a composite key. Which takes to primary keys in order to uniquely identify a row.
    • Create tables in the correct order to handle foreign keys.
  • Import each CSV file into the corresponding SQL table. Note be sure to import the data in the same order that the tables were created and account for the headers when importing to avoid errors.

Data Analysis

  1. List the following details of each employee: employee number, last name, first name, sex, and salary. query_1.png

  2. List first name, last name, and hire date for employees who were hired in 1986.

query_2.png

  1. List the manager of each department with the following information: department number, department name, the manager's employee number, last name, first name.

query_3.png

  1. List the department of each employee with the following information: employee number, last name, first name, and department name.

query_4.png

  1. List first name, last name, and sex for employees whose first name is "Hercules" and last names begin with "B."

query_5.png

  1. List all employees in the Sales department, including their employee number, last name, first name, and department name.

query_6.png

  1. List all employees in the Sales and Development departments, including their employee number, last name, first name, and department name.

query_7.png

  1. In descending order, list the frequency count of employee last names, i.e., how many employees share each last name.

query_8.png

Bonus

As you examine the data, you are overcome with a creeping suspicion that the dataset is fake. You surmise that your boss handed you spurious data in order to test the data engineering skills of a new employee. To confirm your hunch, you decide to take the following steps to generate a visualization of the data, with which you will confront your boss:

  1. Import the SQL database into Pandas.

  2. Create a histogram to visualize the most common salary ranges for employees.

Salary_Distribution.png

  1. Create a bar chart of average salary by title.

Average_Salary_Title.png

Epilogue

Evidence in hand, you march into your boss's office and present the visualization. With a sly grin, your boss thanks you for your work. On your way out of the office, you hear the words, "Search your ID number." You look down at your badge to see that your employee ID number is 499942.

About

sql-challenge

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors