Without grouping operators, we have to do a little bit of a roundabout method to get the result needed:
Take the Cartesian product of the table with itself (I'll now refer to the attributes as
EMP1
,EMP2
,Worktype1
, etc. Note for "proper" relational algebra, you would have to rename these attributes prior to the Cartesian product).Select tuples with
EMP1 = EMP2
,Season1 = Season2
,WorkType1 != WorkType2
. Note some definitions of relational algebra do not allow!=
in a predicate. It's still possible without it, but more workarounds would be needed. I'll assume I can use it.Project and rename
EMP1, WorkType1, Season1
to your original attribute names. You now have a relation containing instances where a worker has worked on more than one work type in a season.Take the set difference of your original table with the one obtained in Step 3. This relation only has instances where a worker only worked on one work type in a season.
- Project the
EMP#
attribute.