Reputation: 1
I am looking to see how I can combine the results of one query into another expressed in TRC format.
Question
Retrieve the names of employees who make at least $10,000 more than the employee who is paid the least in the Company.
DB Setup
EMPLOYEE: fname , minit , lname, ssn , bdate , address , sex , salary , superssn , dno DEPARTMENT: dname dnumber , mgrssn , mgrstartdate DEPT_LOCATIONS: dnumber , dlocation PROJECT: pname , pnumber , plocation , dnum WORKS_ON: essn , pno , hours DEPENDENT: essn , dependent_name , sex , bdate , relationship
I have thus figured out so far how to find the employee with the minimum salary from the link How would I find the highest/largest of something with relation algebra, domain relational calculus and tuple relational calculus and from http://www.cs.princeton.edu/courses/archive/spr00/cs425/soln_from_text_midterm.pdf (page 32, question 6, 7, and 8 all use this logic with answers further down).
I am having difficulty taking the results of the minimum employee and then adding 10000 to it. I believe the rest of the query should be simple. I have the following to generate the minimum salary employee, but obviously this does not return employees above this.
{e1.salary |
EMPLOYEE(e1)
and NOT (∃e2) (EMPLOYEE(e2) and (e2.salary<e1.salary))
}
Upvotes: 0
Views: 1352
Reputation: 1
Upon further review, I think the following will solve 2nd question...
{emp.fname, emp.minit, emp.lname | EMPLOYEE(emp) and (∃x) ( EMPLOYEE(x) and NOT (x.salary>emp.salary)) and x.dno=emp.dno)}
While I may need to touch this up, I think it has the basic idea. It is definitely somewhat removed coming from an OOP perspective and passing values up the chain. Thanks again!
Upvotes: 0
Reputation: 1
I would think that you can add 10000 to e2.salary directly in the condition i.e. e2.salary + 10000 < e1.salary
Upvotes: 0