- departments: Stores department details.
- titles: Contains job titles.
- employees: Stores personal employee information.
- salaries: Tracks salary details.
- dept_emp: Maps employees to departments.
- dept_manager: Tracks department managers.
Several SQL queries were used to extract insights from the database, including:
- Employee Salary Report: basic select
- Employees Hired in 1986: where clause
- Department Managers: joining, formatting
- Employee Department Details: joining, formatting
- Employees Named 'Hercules B...': regexing
- Employees in Sales and Development: boolean operations
- Most Common Last Names: aggregation
- PostgreSQL
-
Clone this repository:
git clone https://github.com/constcorrectness/sql-challenge.git cd sql-challenge -
Open PostgreSQL and create a database:
CREATE DATABASE employee_db;
-
Load the schema and data:
psql -d employee_db -f schemas/all_schemas.sql psql -d employee_db -f data/load_tables.sql
To run queries, connect to the database using:
psql -d employee_dbThen, execute any SQL query by running:
SELECT * FROM employees LIMIT 10;This project is licensed under the GNU GPL v3