TRC query Relational calculus

+1 vote

Consider the relation employee(ssn,name, sex, Dno) and department(Dnumber, Dname, Mgr_ssn) with ssn and Dnumber as keys in employee and department schemas respectively. Here Dnumber in the department is a foreign key referring to the Dno in employee. What does the following relational calculus query produces? [Assume each department has a manager]


{e.name | employee(e) ∧ (∀d)(¬department(d) ∨ d.Dnumber ≠ e.Dno ∨ (d.Mgr_ssn ≠ e.ssn) ∨ (e.sex = ‘male’))}

My answer is "Names of all male employees who are not managers" because other way of saying this statement is "There exist a department in which the female employee is the manager"

is it correct or how to interpret it??

asked Nov 27, 2016 in DBMS by hi2saifgmail-com (2,770 points)

1 Answer

0 votes

(∀d)(¬department(d) ∨ d.Dnumber ≠ e.Dno ∨ (d.Mgr_ssn ≠ e.ssn) ∨ (e.sex = ‘male’))}

Let us take negation of it. ( and conditions are easier to understand than or)

\existsd (department(d) \Lambda d.Dnumber = e.Dno  \Lambda d.Mgr_ssn = e.ssn)\Lambda(e.sex = ‘female’))}

there is some d which is department and whose department number matches with e's department number and its manager is e and e is female

That means "there is some Department for which our e (e is also female) is a manager and also belongs to same department"

Since we interpreted negation of the statement.

So original statement would be " It is false that there is some Department for which our e (e is also female) is an employee working there and manager"

 

Finally e (e is also female) is not a manager to any department where he works

Now we interpret all together

It prints e.name when e is an employee and  female and not a manager to any department where he works

 

answered Nov 27, 2016 by getgatebook (23,090 points)
...