The Escuela

← Relational algebra: all 5 exercises

Databases · Free practice

Relational Algebra, Exercise 3: Division

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)

  • Division R ÷ S returns the values of R that are paired with every row of S.
  • Use it for questions with “all”: πeid, pid(works_on) ÷ πpid(projects).
  • Project exactly the columns you need first; extra columns (like hours) break the division.

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