Project Overview: Objectives
Project Overview: Objectives
Project Overview
This project focuses on applying relational algebra operations to query a structured database
schema. The database consists of four primary tables:
The goal is to write relational algebra expressions to solve specific business queries, such as
finding employees working on multiple projects, departments with no employees, or employees
earning above the average salary.
Objectives
• Understand Core Relational Algebra Operations: Selection (σ), Projection (π), Join (⨝),
Set Difference (−), Aggregation (γ), and Division (÷).
• Translate Business Queries into Formal Expressions: Convert real-world questions (e.g.,
"Who works in the IT department?") into relational algebra.
• Validate Results with Sample Data: Test each query against a sample dataset to ensure
accuracy.
• Employee Table
1
102 Yohannes D02 6500
• Project Table
• Works_on Table
101 P10 45
102 P20 35
103 P10 40
104 P20 15
101 P20 10
• Department Table
D01 IT Building A
2
D02 Finance Building B
D03 HR Building C
Solution:-
Explanation: We combine employee and work records, pick only those working >30 hours, and
list their names. Expected Output:
101 Abebe 45
103 Helen 40
Explanation: Count projects per employee, keep only those with >1 project, then show names.
Expected Output:
emp_name
Abebe
3
Explanation: Uses set difference to find employees absent in Works_on. Compare full employee
list against those with project assignments to find the employees not working on any projects.
Expected Output:
emp_id emp_name
105 Dawit
Explanation: Joins all tables and filters for dept_name = 'IT'. we will trace project-department
connections to find IT projects, then list workers.
Expected Output:
emp_name emp_name
Helen Abebe
Explanation: we will compare all departments against those with linked employees. Subtract
departments linked to employees from all departments.
Expected Output:
dept_name
HR
Expected Output:
emp_id emp_name
102 Yohannes
104 Mikias
Explanation: Division finds employees associated with every project (Check if any employee
appears in all project assignments). But since there are no employees who work on every project
the output will be empty.
Expected Output:
emp_name
empty
Explanation: here we will sum up the employees’ work hours across all projects and display the
total along with employee id. Sums hours per employee (including NULL for non-workers).
Expected Output:
emp_id total_hours
101 55
102 35
103 40
5
104 15
105 Null
9) Task 9: Departments with Avg Salary > 10,000 Relational Algebra: π_{dept_name}
(σ_{avg_salary > 10000} (γ_{dept_id; AVG(salary)→avg_salary} (Employee) ⨝ Department))
Explanation: So here we will calculate department salary averages and filter based on that. Since
our highest is Finance at 6,750 average we won’t have a department with average salary more
than 10,000.
Expected Output:
Dept_name
empty