Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relational algebra - List the names of employees who do not work in the project 1

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

like image 642
Johny Avatar asked Oct 15 '25 18:10

Johny


2 Answers

You first find all the employees who do work on the project. Those who don't are produced by relational difference (minus) operator.

like image 129
Tegiri Nenashi Avatar answered Oct 19 '25 23:10

Tegiri Nenashi


Thank you for the tip Tegiri.
The solution is:

π name (Employee) - ( π name (σ project_cod = 1 (Employee ∞ Work)))
like image 34
Johny Avatar answered Oct 19 '25 23:10

Johny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!