I've the following tables:
Employee
|name|employee_cod|
Project
|name|project_cod|
Work
|employee_cod|project_cod|
So, how can I list the names of employees who not work, for example, in the project with project_cod = 1, with relational algebra?
The following not work:
π(employee.name(σ work.project_cod != 1 (Employee ∞ Work ∞ Project)
Because if I have the following data in work table:
| employee_cod | project_cod |
-------1--------------1-------
-------1--------------2-------
-------1--------------3-------
-------2--------------2-------
This σ work.project_cod != 1 will result in:
| employee_cod | project_cod |
-------1--------------2-------
-------1--------------3-------
-------2--------------2-------
But the employee with code = 1 should not be returned, because it participates in project 1
You first find all the employees who do work on the project. Those who don't are produced by relational difference (minus) operator.
Thank you for the tip Tegiri.
The solution is:
π name (Employee) - ( π name (σ project_cod = 1 (Employee ∞ Work)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With