• edited by
22,697 views
62 62 votes

Given the relations

  • employee (name, salary, dept-no), and
  • department (dept-no, dept-name,address),

Which of the following queries cannot be expressed using the basic relational algebra operations $\left(\sigma, \pi,\times ,\Join, \cup, \cap,-\right)$?

  1. Department address of every employee
  2. Employees whose name is the same as their department name
  3. The sum of all employees' salaries
  4. All employees of a given department

4 Answers

Best answer
72 72 votes

Possible solutions, relational algebra:

(a) Join relation using attribute dpart_no.

  • $\Pi_{\text{address}} (\text{emp} \bowtie  \text{depart})$ OR 
  • $\Pi_{\text{address}} (\sigma_{ \text{emp}.\text{depart_no.}=\text{depart}.\text{depart_no}.} (\text{emp} \times \text{depart}))$

(b)

  • $\Pi_{\text{name} } (\sigma_{\text{emp}.\text{depart_no.}=\text{depart}.\text{depart_no.} \wedge \text{emp.name} = \text{depart}.\text{depart_name}} (\text{emp} \times \text{depart}))$ OR
  • $\Pi_{\text{name}} (\text{emp} \bowtie _{ \text{ emp.name} = \text{depart}.\text{depart_name}} \text{depart})$

(d) Let the given department number be $x$ 

  • $\Pi_{\text{name}} (\sigma_{ \text{emp}.\text{depart_no.}=\text{depart}.\text{depart_no.} \wedge \text{depart_no.} = x} (\text{emp} \times \text{depart}))$ OR 
  • $\Pi_{\text{name}} (\text{emp} \bowtie _{\text{ depart_no}.=x} \text{depart}) $

(c) We cannot generate relational algebra of aggregate functions using basic operations. We need extended operations here. 

Option (c).

• edited by
21 21 votes
aggregate functions are not supported by relational algebra ie. sum,average,maximum,minimum and count.So c is the answer
0 0 votes
in option c we need aggregate function but in relational algebra there is no any aggregate function thats why it is impossible to express

 
–5 –5 votes
(b)

we need to do a self join, for which we need rename operator(row symbol)
Answer:
Position:
Show:

Related questions

51 51 votes
8 answers 8 answers
17.6k
17.6k views
Kathleen asked Sep 14, 2014
17,565 views
A multiset is an unordered collection of elements where elements may repeat any number of times. The size of a multiset is the number of elements in it, counting repetiti...
62 62 votes
5 answers 5 answers
26.7k
26.7k views
Kathleen asked Sep 23, 2014
26,693 views
Consider the join of a relation $R$ with a relation $S$. If $R$ has $m$ tuples and $S$ has $n$ tuples then the maximum and minimum sizes of the join respectively are$m+n$...
51 51 votes
2 answers 2 answers
21.0k
21.0k views
gatecse asked Aug 5, 2014
20,989 views
Register renaming is done in pipelined processors:as an alternative to register allocation at compile timefor efficient access to function parameters and local variablest...
47 47 votes
4 answers 4 answers
14.9k
14.9k views
Kathleen asked Sep 29, 2014
14,867 views
Let $R (a, b, c)$ and $S(d, e, f)$ be two relations in which $d$ is the foreign key of $S$ that refers to the primary key of $R$. Consider the following four operations $...