Hi, let's work on an awesome database.
-
An employee databse is here to research employees of the corporation from the 1980s and 1990s. All that remain of the database of employees from that period are six CSV files.
-
Design the tables to hold data in the CSVs, import the CSVs into a SQL database, and answer questions about the data.
-
In other words, perform:
Data Engineering using SQL and Postgres Data Analysis using Python
- Python 3.6 or higher
- PostgreSQL database
- pgAdmin
-
Inspect the CSV files, and then sketch an Entity Relationship Diagram of the tables.
-
To create the sketch, we use a QuickDBD as one of best tool for design ERD.
-
Here is how the database model prepared.
Create the Employees_DB database in pgAdmin using SQL.
-
Create a table schema for each of the six CSV files.
-
Remember to specify the data types, primary keys, foreign keys, and other constraints.
-
Create the tables in the correct order to handle the foreign keys.
-
Inspecting the data files, I experience that sometimes there is datestyle format difference for different databases.
-
For these files I need to set the datestyle in the "Employees_DB" database which corresponds to the same in CSV files.
-
After setting the above datestyle format for the particular database, I could able to import the data.
-
Then, here we can see how successfully the process for all six files completed.
To look at a glance, one of the main table query is here (with first five rows):
Our observation of data analysis depicts the information as required for each query (with first 10 rows).
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).