The Escuela

← Relational algebra: all 5 exercises

Databases · Free practice

Relational Algebra, Exercise 4: Set difference

Watch the worked solution by Dr. J. Ubaldo Quevedo, then practice as many times as you want: every click of New database gives you new data to work with.

1. Watch

The relations: employees(eid, name, salary, did, m_did) · projects(pid, description) · works_on(eid, pid, hours) · departments(did, location)

  • Set difference R − S keeps the rows of R that are not in S. Both must have the same columns.
  • “Working on zero projects” = all eids minus the eids that appear in works_on.
  • Join back to employees to get the names.

2. Try it yourself

Practice as many times as you want. New database fills the tables with new employees, salaries and hours, and New question changes the details of the query. It's free, and you don't need an account.

Correct so far: 0