95 votes 95 votes Consider the relation employee(name, sex, supervisorName) with name as the key, supervisorName gives the name of the supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce? $\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg employee\left(x \right) \vee x.supervisorName \neq e.name \vee x.sex = ``male" \right]\right\}$ Names of employees with a male supervisor. Names of employees with no immediate male subordinates. Names of employees with no immediate female subordinates. Names of employees with a female supervisor. Databases gatecse-2007 databases relational-calculus normal + – Kathleen asked Sep 21, 2014 Kathleen 23.7k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments KUSHAGRA गुप्ता commented Oct 28, 2019 i edited by KUSHAGRA गुप्ता Jan 8, 2020 reply Follow Share $\{e.name|employee(e)\wedge \forall (x)[(employee(x)\wedge x.supervisorName=e.name)\rightarrow x.sex=male]\}$ Print the names of those employees who are a supervisor but should not be a supervisor of a female employee Ans: C: Names of employees with no immediate female subordinates. 12 votes 12 votes Deepak Poonia commented Nov 13, 2023 reply Follow Share Detailed Video Solution: https://youtu.be/RgNpwKnGWPU 2 votes 2 votes Shukla_ commented Nov 27, 2023 i edited by Shukla_ Nov 27, 2023 reply Follow Share we can rewrite P → Q as ¬P V QSo we can rewrite it as ∀x(employee(x) → (x.supervisorname≠e.name V x.sex=”male” )Or ∀x ∈ employee(x) (x.supervisorname≠e.name V x.sex=”male”)Or ∀x ∈ employee(x)( ¬(x.supervisorname=e.name) V x.sex=”male”)Or ∀x ∈ employee(x)( x.supervisorname=e.name → x.sex=”male”)So TRC query will be {e.name | employee(e)∧ ∀x∈employee(x)( x.supervisorname=e.name → x.sex=”male”) which gives those employee names for which if they are supervisor then they are the supervising only male employees. Hence Option C 0 votes 0 votes Please log in or register to add a comment.
Best answer 227 votes 227 votes OR ($\vee$) is commutative and associative, therefore i can rewrite given query as: $\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg employee\left(x \right) \vee x.sex = ``male" \vee x.supervisorName \neq e.name \right]\right\}$ $\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg (employee\left(x \right) \wedge x.sex \neq ``male") \vee x.supervisorName \neq e.name \right]\right\}$ $\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[ (employee\left(x \right) \wedge x.sex \neq ``male") \Rightarrow x.supervisorName \neq e.name \right]\right\}$ $\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[ (employee\left(x \right) \wedge x.sex =``female") \Rightarrow x.supervisorName \neq e.name \right]\right\}$ It is clear now they are saying something about female employees, This query does not say anything about male employees. Therefore Option A and B are out of consideration. This query retrieves those $e.name$ who satisfies this condition: $\forall x [(employee(x)\wedge x.sex="female")\Rightarrow x.supervisorName\neq e.name]$ Means retrieves those e.name, who is not a supervisor of any female employees. i.e it retrieves name of employees with no female subordinate. (here "immediate" is obvious, as we are checking first level supervisor.) Hence, option C. Sachin Mittal 1 answered Dec 12, 2016 • edited Jun 22, 2018 by Milicevic3306 Sachin Mittal 1 comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments tusharp commented Apr 25, 2019 reply Follow Share Apply De Morgan law after AND condition. For all P(x) == There does not exist ~P(x). It will be simple after that. 0 votes 0 votes Neel123 commented Aug 5, 2022 reply Follow Share Why we are putting () around first two terms only and not the third one in the second step? 0 votes 0 votes sk91 commented Dec 27, 2022 reply Follow Share @Neel123 As mentioned in the answer, $\lor$ is commutative and associative. So, expression $A \lor B \lor C$ can be considered as either $((A \lor B)\lor C)$ (or) $(A\lor(B \lor C))$ 0 votes 0 votes Please log in or register to add a comment.
51 votes 51 votes {e.name∣employee(e)∧(∀x)[¬employee(x)∨x.supervisorName≠e.name∨x.sex=‘‘male"]} ...(1) By Using De-morgan's law We can write expression ∀x(P(X)) as NOT ∃x(NOT P(X)). Using this concept, we rewrite the conditon (1) as given in question above {e.name∣employee(e)∧ NOT(∃x)[employee(x) ^ NOT x.supervisorName≠e.name ^ NOT x.sex=‘‘male"]} ...(2) Considering only 2 genders are represented in the database as either male or female we can again rewrite expression (2) as {e.name∣employee(e)∧ NOT(∃x)[employee(x) ^ x.supervisorName = e.name ^ x.sex=‘‘female"]} ...(3) Now it is easier to read the expression above. It Says, for a tuple of employee, there must not be a case that this employee being considered is supervisor of some female employee. That means it selects all those employee who do not supervise any female employee hence do no have any immediate female sub-ordinate. Hence, Ans (C) Ayush Upadhyaya answered Oct 3, 2017 Ayush Upadhyaya comment Share Follow See all 10 Comments See all 10 10 Comments reply Show 7 previous comments Ayush Upadhyaya commented Jan 14, 2019 reply Follow Share @SomeEarth-if you have that method, please share fast, we are always in search of better methods. :) I am not sure about whether venn diagram method will work here. 0 votes 0 votes SomeEarth commented Jan 14, 2019 reply Follow Share while i was writing the earlier comment I tried my level best to visualize the inner query and try to present u but I wasn't able to do that so I thought to share that idea with u. (but unfortunately we all are running short on time so I guess I'll do the Brainstroming on this after Gate on this q and for other question as well. (Multiple possible answer for any question makes it easier to Understand ) ((as u and other Senior member of GO community are doing)) 0 votes 0 votes KunuSwavik commented Oct 23, 2021 reply Follow Share @ayush sir , I didn't get the term " x.supervisorName = e.name" can you please elaborate ? 0 votes 0 votes Please log in or register to add a comment.
38 votes 38 votes Query is selecting e such that e is an employee and for all x, either x is not an employee or x's supervisor's name is not e.name or x is male. So, this is equivalent to saying, select all employees who don't have an immediate female subordinate. (Assuming there is no transgender). (C) option. Arjun answered Dec 18, 2014 Arjun comment Share Follow See all 16 Comments See all 16 16 Comments reply Vikrant Singh commented Dec 18, 2014 reply Follow Share thanks Arjun, nice way of explaining :) 3 votes 3 votes lgau0522 commented Jan 21, 2015 reply Follow Share i think (not)(employee(x)) doesnt mean those tuples which are not employee Read this->http://en.wikipedia.org/wiki/Tuple_relational_calculus there it says-> if f is in F[S,type] then the formula " ¬ f " is also in F[S,type] means (not)(employee(x)) --> employee(x) will be true for all tuples(i.e x) of employee so (not)(employee(x)) will give false for every tuple of employee (SO in all the answer given has the same meaning) but here is the difference.. x in (not)(employee(x)) will never get a tuple outside of emloyee table hence it simply means " "DON'T INCLUDE ANY EMPLOYEE" which is equivalent to " x is not an employee" only in english Not in database because "x is not an employee" will check for every tuple in database an UNSAFE QUERY (which actually isn't happening) but anyways the answer would be same 3 votes 3 votes Arjun commented Jan 21, 2015 reply Follow Share :O Actually the wiki line if f is in F[S,type] then the formula " ¬ f " is also in F[S,type] just means if t is a formula, then ¬t is also a formula. For these topics I find wikipedia quite confusing to follow. Google is much better. http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter3/node11.html 0 votes 0 votes lgau0522 commented Jan 21, 2015 reply Follow Share http://people.cs.pitt.edu/~chang/156/10calculus.html under safe queries so we can say above query is unsafe and it actually is checking every tuple of database??? 3 votes 3 votes Arjun commented Jan 21, 2015 reply Follow Share Yes. That is true. 0 votes 0 votes Piyush Kapoor commented Aug 26, 2016 reply Follow Share sir, I am not getting what does immediate subordinate means . Plz tell 0 votes 0 votes pC commented Sep 12, 2016 reply Follow Share @arjun Sir how did you conclude answer from Query is selecting e such that e is an employee and for all x, either x is not an employee or x's supervisor's name is not e.name or x is male. 0 votes 0 votes Arjun commented Sep 12, 2016 reply Follow Share Well, that is difficult to explain. Guess, I tried to find such an "x" :) 1 votes 1 votes Rajesh Raj commented Sep 25, 2016 reply Follow Share staff lower in rank or position is called subordinate 2 votes 2 votes Rajesh Raj commented Sep 25, 2016 reply Follow Share Sir I m not reaching the answer from this line "Query is selecting e such that e is an employee and for all x, either x is not an employee or x's supervisor's name is not e.name or x is male. " plzz elaborate 1 votes 1 votes kvkumar commented Dec 6, 2016 reply Follow Share can we replace above query into p ->q {e.name∣employee(e)∧ (∀x)[[employee(x) and x.supervisorName=e.name ] ->x.sex=‘‘male"] } now it is simple to analyse.. 4 votes 4 votes ashish gusai commented Jan 3, 2017 reply Follow Share most politically correct answer i've seen in this website 2 votes 2 votes Udit Gupta 1 commented Jul 20, 2017 reply Follow Share @kvkumar Loyal Nice explanation. In words : If e is an employee in an organization then below test conditions should be true for this employee (e) to be displayed : We will consider all the members in the organization one by one (say x) and the below condition should be true for all of them: If x is an employee in the same organization as e and e is the supervisor of this x then x should be male If the above loop fails for even one employee then e won't be selected for display. In short, it means that all the employee (e) are selected for display which have only male employee (and hence no female employees) working under them. 5 votes 5 votes smelly indian commented Sep 10, 2017 i reshown by smelly indian Sep 10, 2017 reply Follow Share x's supervisor's name is not e.name, can someone explain me this line. 0 votes 0 votes Anu007 commented Jan 5, 2018 reply Follow Share wait for a day i will explain with example. 0 votes 0 votes VYAN_jy commented Oct 16, 2022 reply Follow Share I think it means either e is not a supervisor of any employee and if he/she is then his subordinate is male only. 0 votes 0 votes Please log in or register to add a comment.
6 votes 6 votes Apply de morgen laws and then simplify as follows. jatin saini answered Jan 11, 2017 jatin saini comment Share Follow See all 0 reply Please log in or register to add a comment.