Skip to content

SpendleyT/sql-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

SQL Challenge

Module 9 - SQL Challenge

Overview

As a way of demonstrating basic SQL proficiency, the activities outlined below are intended to cover a number of important SQL functions and options. The dataset provided reflects a simple summary of a company's employees and their relevant attributes. This project will span the following activities:

  • Analyze a data set and create an ERD that reflects the data.
  • Write a schema to create the necessary tables in a database.
  • Create said database in PostgreSQL - in this case, using pgAdmin.
  • Write sql queries to import the data set into its respective tables.
  • Write a collection of SQL queries to demonstrate both the successful import of the data and an understanding of querying principles.

Project Files

Project Output ('sql-challenge/EmployeeSQL'):

  • ERD: ERD-employees.png
  • Schema: employee_schema.sql
  • Data Load: data_load.sql
  • Data Queries: queries.sql

Project Input ('sql-challenge/data'):

  • Departments: departments.csv
  • Department / Employee Link: dept_emp.csv
  • Department / Manager Link: dept_manager.csv
  • Employees: employees.csv
  • Employee Salaries: salaries.csv
  • Employee Titles: titles.csv

Execution Steps

  1. Utilizing pgAdmin, create database for this exercise ('challenge9_db').
  2. Utilizing the QueryTool, open the employee_schema.sql and execute the script.
  3. To load the data, you have 2 options:
    • Import the .csv files into their respective tables utilizing the import function within pgAdmin.
    • Edit the data_load.sql file with the explicit path to the local.repository. Then, via QueryTool, execute the script.
  4. Open the queries.sql file in QueryTool, and execute each script independently to review the results.

Project Assignment

Data Modeling Inspect the CSV files, and then sketch an Entity Relationship Diagram of the tables. To create the sketch, feel free to use a tool like QuickDBDLinks to an external site..

Data Engineering Use the provided information to create a table schema for each of the six CSV files. Be sure to do the following:

  • Remember to specify the data types, primary keys, foreign keys, and other constraints.
  • For the primary keys, verify that the column is unique. Otherwise, create a composite keyLinks to an external site., which takes two primary keys to uniquely identify a row.
  • Be sure to create the tables in the correct order to handle the foreign keys.
  • Import each CSV file into its corresponding SQL table.

Data Analysis

  • List the employee number, last name, first name, sex, and salary of each employee.
  • List the first name, last name, and hire date for the employees who were hired in 1986.
  • List the manager of each department along with their department number, department name, employee number, last name, and first name.
  • List the department number for each employee along with that employee’s employee number, last name, first name, and department name.
  • List first name, last name, and sex of each employee whose first name is Hercules and whose last name begins with the letter B.
  • List each employee in the Sales department, including their employee number, last name, and first name.
  • List each employee in the Sales and Development departments, including their employee number, last name, first name, and department name.
  • List the frequency counts, in descending order, of all the employee last names (that is, how many employees share each last name).

About

Module 9 challenge - sql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages