Relational-Calculus
Question 1 |
Which of the following relational calculus expressions is not safe?
{t|∃u ∈ R1 (t[A] = u[A])∧ ¬∃s ∈ R2 (t[A] = s[A])} | |
{t|∀u ∈ R1 (u[A]= "x" ⇒ ∃s ∈ R2 (t[A] = s[A] ∧ s[A] = u[A]))} | |
{t|¬(t ∈ R1)} | |
{t|∃u ∈ R1 (t[A] = u[A])∧ ∃s ∈ R2 (t[A] = s[A])} |
Question 2 |
Consider the following relational schema:
Student (school-id, sch-roll-no, sname, saddress) School (school-id, sch-name, sch-address, sch-phone) Enrolment(school-id, sch-roll-no, erollno, examname) ExamResult(erollno, examname, marks)
Consider the following tuple relational calculus query:
If a student needs to score more than 35 marks to pass an exam, what does the query return?The empty set | |
schools with more than 35% of its students enrolled in some exam or the other | |
schools with a pass percentage above 35% over all exams taken together | |
schools with a pass percentage above 35% over each exam |
Question 2 Explanation:
Query having the division with
{ x | x ∈ Enrollment ∧ x . school-id = t } | * 100 > 35 }
This is school with enrollment % is 35 or above.
As we are actually taking percentage of
(Total count in which a student has passed from a particular school)/(Total exams taken by all student combined)
Eg: if A passed in 3 and B passed in 4 and they both took 5-5 exam each. Then it is (7/10)
{ x | x ∈ Enrollment ∧ x . school-id = t } | * 100 > 35 }
This is school with enrollment % is 35 or above.
As we are actually taking percentage of
(Total count in which a student has passed from a particular school)/(Total exams taken by all student combined)
Eg: if A passed in 3 and B passed in 4 and they both took 5-5 exam each. Then it is (7/10)
Question 3 |
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?
{e.name|employee(e)∧} (∀x)[¬employee(x) ∨ x.supervisorName ≠ e.name ∨ x.sex = "male"]}
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. |
Question 3 Explanation:
The given Tuple Relational calculus produce names of employees with no immediate female subordinates.