Rebuilding a company's 1980s–1990s employee database from six raw CSV files: designing the schema, loading the data into PostgreSQL, and answering business questions with SQL.
All that remained of the legacy employee database was a set of flat CSV exports: employees, departments, department assignments, managers, salaries, and titles. The goal was to turn them into a working relational database that people could query.
- Data modeling: inspected the CSVs and sketched an entity relationship diagram (ERD) to map how the tables relate
- Data engineering: wrote table schemas with data types, primary keys, foreign keys, and composite keys, then imported each CSV in dependency order
- Data analysis: wrote SQL queries using multi-table
JOINs, date filtering, and aggregation. Examples:- Employee number, name, sex, and salary for every employee
- Employees hired in 1986
- Each department's manager
- Department assignments for every employee
-- Manager of each department
SELECT d.dept_no, d.dept_name, e.emp_no, e.last_name, e.first_name
FROM employee e
JOIN dept_manager dm ON e.emp_no = dm.emp_no
JOIN departments d ON dm.dept_no = d.dept_no;PostgreSQL · SQL · ERD design
| Path | Purpose |
|---|---|
Table Schemas/ |
CREATE TABLE scripts for all 6 tables |
Queries/Data Analysis.sql |
Analysis queries |
Query file.sql |
Additional queries |