2,659 views
4 votes
4 votes
Given the following relational schemas
Student (studId, name, age, sex, deptNo, advisor)
Department (deptId, DName, hod, phoneNo)
Which of the following will be the TRC query to obtain the department names that do not have any girl students?

1. {d.Dname | department(d) ∧ ~ ((∃(s)) student(s) ∧ s.sex ≠ ‘F’ ∧ s.deptNo = d.deptId)}

2. {d.Dname | department(d) ∧ ((∀ (s)) student(s) ∧ s.sex ≠ ‘F’ ∧ s.deptNo = d.deptId)}

3. {d.Dname | department(d) ∧ ~ ((∃(s)) student(s) ∧ s.sex = ‘F’ ∧ s.deptNo = d.deptId)}

3 Answers

1 votes
1 votes
{d.Dname | department(d) ∧ ~ ((∃(s)) student(s) ∧ s.sex = ‘F’ ∧ s.deptNo = d.deptId)}
0 votes
0 votes

option 3 is correct.

1st option gives all dept which have no male student

2nd option gives a dept in which all  the male students are studying(if so)

 

0 votes
0 votes

Answer :- 3.

let assume Tables

Department :-

Dep ID Name
1 A
2 B
3 C

Student:-

stud Id sex Dept no
10 M 1
20 M 1
30 M 2
40 F 2
50 F 3
60 F 3

 

So First:- 

There Exist some row in Student table where sex is not female. Using this we can get Dept no 1 and 2. And negation of this query will give 3 in which all student sex is female.

For Second :-

All student are not Female means atleast one student is male so this query give dept no 1 and 2 both.

For third:-

Inner query gives Dept no for which there is Some students are female then we get 2 and 3 and negation of this query gives Dept no 1.

edited by

Related questions

1 votes
1 votes
2 answers
3
tarunmaganti asked Apr 15, 2018
750 views
If there are three tables to choose from -Sailors(sid,sname); Reserves(sid,bid); Boats(bid,color)Question is to choose a sailor who reserved a red boat.My question is wha...
0 votes
0 votes
0 answers
4
Tuhin Dutta asked Dec 10, 2017
679 views
What does the following tuple relational calculus query produce?• Student (Student_name, street, city)• Score (Student_name, Branch_name, marks)• Branch (Branch_nam...