name
name

Reputation: 419

Queries in tuple relational calculus re employee department and minimum & maximum salary?

I have to solve the queries using tuple relational calculus and I just want to know if I did them correctly. I'm using this database:

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

Q1: Retrieve the names of employees who make at least $10,000 more than the employee who is paid the least in the Company.

{e.Lname, e.Fname | EMPLOYEE(e) AND (∃b) (EMPLOYEE (b) AND e.Salary >= 
10000 + b.Salary AND NOT (∃a) (EMPLOYEE(a) AND b.Salary > a.Salary))}

Q2: Retrieve the names of all employees who work in the department that has the employee with the highest salary among all employees.

{e.Lname, e.Fname | EMPLOYEE(e) AND (∃b) (EMPLOYEE (b) AND e.dno = 
b.dno AND NOT(∃a)(EMPLOYEE(a) AND a.Salary > b.Salary))}

Any help will be much appreciated.

edit: Assume that only one employee can have the highest/lowest salary.

Upvotes: 1

Views: 1106

Answers (1)

philipxy
philipxy

Reputation: 15118

Guessing at the meaning of base relations, the natural language agrees with the calculus. Nb technically the answer can't be found if you don't give the meanings (predicates) for the base tables. As to whether you got those right answers via correct reasoning, you'd have to give yours. PS The questions are flawed if there can be multiple employees with highest or lowest salary.

Upvotes: 1

Related Questions