0% found this document useful (0 votes)
10 views

Capstone Project 2-SQL-DataETL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Capstone Project 2-SQL-DataETL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Design a TechCorp Database and Analyse Using SQL Queries

Scenario:
You are tasked with designing and implementing a database for a fictional company called
"TechCorp" that manages employees, departments, projects, and their respective budgets.
The database must enforce constraints to ensure data integrity and support queries for data
analysis and reporting.

1. Database Design
Entities and Relationships:
- Employees: Stores information about employees.

Total Employees: 186

- Departments: Stores information about company departments.

Total Departments: 20
- Projects: Stores information about projects, including the department responsible and the
budget allocated.

Total Projects: 50

- ProjectAssignments: Tracks which employees are assigned to which projects, along with
their roles and the hours they have worked.

Total Project Assignments: 50


2. Data Insertion
Insert sample data into each table. Ensure the data is diverse enough to allow for meaningful
queries.
 Done by Using -> INSERT INTO clause.

 For query no. 3, I was getting no output, so I added the row in Project Assignment to have a
output.

 For query no. 4, No Outputs were shown because CURRDATE is way more than any of the
EndDate.So, I added few columns to get some output.

3. Queries for Data Analysis


Write complex SQL queries to extract and analyse data based on the topics covered:
1. Employee and Department Analysis
- Retrieve the list of employees along with their department names and sort them by
department.

OUTPUT:
2. Project Budget Analysis
- Calculate the total budget allocated to each department and identify the department
with the highest total budget.

To identify the department with the maximum total budget:


Just descended the total_budget and put LIMIT of 1
3. Employee Workload Analysis
- List all employees along with the total number of hours they have worked on projects,
and filter for employees who have worked more than 1000 hours.

NOTE: Earlier, no output was shown, so added a row to get some Output.
4. Project Timeliness
- Identify projects that are behind schedule by comparing the current date with the
`EndDate`.

5. Salary and Budget Comparison


- Compare the total salary of employees in each department to the budget allocated to
that department's projects.
6. Demonstrate usage of CTE and windows function
Q. For each project_id, calculate the running total budget.
Use case of this could be to find out, how project budget increases as running total budget
increases.

Q. Use CTE to find out the highest paid employee in each department
Use case of this question could be to find out the seniority based on salaries in department.

You might also like