GATE 2007
184 questions
MCQ 1841-mark 184
Questions 146–150 of 184
Consider a selection of the form , where r is a relation with 1000 tuples. Assume that the attribute values for A among the tuples are uniformly distributed in the interval [0, 500]. Which one of the following options is the best estimate of the number of tuples returned by the given selection query ?
Answer: (D)
The values of are uniformly spread over , so the fraction of tuples with is the length of divided by the length of :
Number of tuples .
Answer: (D)
Number of tuples .
Answer: (D)
Information about a collection of students is given by the relation studinfo(, name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or taken) what course(s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent?
Answer: (B)
Read the expression from the inside.
1. is the set of ids of female students.
2. Its cross product with gives every pair (female student, course).
3. Subtracting removes the pairs where the student really took the course. What remains is every pair (female student , course ) where is not enrolled in .
4. Projecting on gives the courses where at least one female student is not enrolled.
Since every course has at least one female student, the female students enrolled in such a course are some, but not all, of the female students: a non-empty proper subset.
Example: students 1 (M), 2 (F), 3 (F); enroll = . The pairs are . After subtracting enroll only is left, so the result is . Only female student 2 is in .
(A) is the opposite: such courses are left out of the result. (C) is not what the expression computes, since it looks only at female students.
Answer: (B)
1. is the set of ids of female students.
2. Its cross product with gives every pair (female student, course).
3. Subtracting removes the pairs where the student really took the course. What remains is every pair (female student , course ) where is not enrolled in .
4. Projecting on gives the courses where at least one female student is not enrolled.
Since every course has at least one female student, the female students enrolled in such a course are some, but not all, of the female students: a non-empty proper subset.
Example: students 1 (M), 2 (F), 3 (F); enroll = . The pairs are . After subtracting enroll only is left, so the result is . Only female student 2 is in .
(A) is the opposite: such courses are left out of the result. (C) is not what the expression computes, since it looks only at female students.
Answer: (B)
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?
Answer: (C)
The condition must hold for every tuple :
Reorder the OR terms (OR is commutative and associative):
Use , with = (employee(x) and x.sex is not male). Since sex is male or female, this is:
So for every female employee , her supervisor is not . Employee is not the direct supervisor of any female employee: has no immediate female subordinates.
Options (A) and (D) talk about the supervisor of , but the query compares with , so is a subordinate of . Option (B) is wrong because male subordinates are allowed; only female ones are ruled out.
Answer: (C)
Reorder the OR terms (OR is commutative and associative):
Use , with = (employee(x) and x.sex is not male). Since sex is male or female, this is:
So for every female employee , her supervisor is not . Employee is not the direct supervisor of any female employee: has no immediate female subordinates.
Options (A) and (D) talk about the supervisor of , but the query compares with , so is a subordinate of . Option (B) is wrong because male subordinates are allowed; only female ones are ruled out.
Answer: (C)
Consider the table employee(empId, name, department, salary) and the two queries Q1 ,Q2 below. Assuming that department 5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which one of the statements is TRUE for any arbitrary employee table?
Q1 : Select e.empId
From employee e
Where not exists
(Select * From employee s where s.department = "5" and
s.salary >=e.salary)
Q2 : Select e.empId
From employee e
Where e.salary > Any
(Select distinct salary From employee s Where s.department ="5"Answer: (A)
The goal is the employees whose salary is higher than that of every employee in department 5.
Q1: NOT EXISTS (a department-5 employee s with s.salary >= e.salary) means no one in department 5 earns as much as e or more. That is the same as e.salary being greater than every department-5 salary. So Q1 is correct. It works for any table, and a department-5 employee is never returned because he or she is compared with himself or herself.
Q2: e.salary > ANY (department-5 salaries) is true when e.salary is greater than at least one department-5 salary, that is, greater than the lowest one. This is weaker than the goal.
Example: department 5 salaries 30, 50, 80, and other employees with salaries 90 and 10. Q1 returns only the one with 90. Q2 returns the ones with 90 and also those with 50 and 80 in department 5, which are above the lowest salary only. So Q1 and Q2 differ, and only Q1 is correct.
Answer: (A)
Q1: NOT EXISTS (a department-5 employee s with s.salary >= e.salary) means no one in department 5 earns as much as e or more. That is the same as e.salary being greater than every department-5 salary. So Q1 is correct. It works for any table, and a department-5 employee is never returned because he or she is compared with himself or herself.
Q2: e.salary > ANY (department-5 salaries) is true when e.salary is greater than at least one department-5 salary, that is, greater than the lowest one. This is weaker than the goal.
Example: department 5 salaries 30, 50, 80, and other employees with salaries 90 and 10. Q1 returns only the one with 90. Q2 returns the ones with 90 and also those with 50 and 80 in department 5, which are above the lowest salary only. So Q1 and Q2 differ, and only Q1 is correct.
Answer: (A)
Consider the following implications relating to functional and multivalued dependencies given below, which may or may not be correct.
i. if and then
ii. if and then
iii. if and then
iv. if and then
Exactly how many of the above implications are valid?
i. if and then
ii. if and then
iii. if and then
iv. if and then
Exactly how many of the above implications are valid?
Answer: (C)
Useful facts: every FD is also an MVD (replication). If and is all the attributes, the MVD is trivial and holds in every relation.
(i) False. Take with tuples . Both and hold, since the tuples are all combinations of B and C values for the same A. But has two different values of , so fails.
(ii) True. From and , the union rule gives . Every FD is an MVD, so .
(iii) False. Take with tuples . Here is trivial, and holds. But fails, since A has two values of C.
(iv) True. From , the decomposition rule gives . Every FD is an MVD, so .
Exactly two implications, (ii) and (iv), are valid.
Answer: (C)
(i) False. Take with tuples . Both and hold, since the tuples are all combinations of B and C values for the same A. But has two different values of , so fails.
(ii) True. From and , the union rule gives . Every FD is an MVD, so .
(iii) False. Take with tuples . Here is trivial, and holds. But fails, since A has two values of C.
(iv) True. From , the decomposition rule gives . Every FD is an MVD, so .
Exactly two implications, (ii) and (iv), are valid.
Answer: (C)