in Databases edited by
14,802 views
43 votes
43 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
in Databases edited by
14.8k views

2 Comments

Ordering, Outer Join, Aggregation and Group of Data is not possible via Basic Relational Algebra.
4
4

Extended relational algebra operations: 

Aggregate function: sum,average,max,min,count,count-distinct

syntax:  ℱ<function-list> (R)

for this : ℱ sum salary (employee)

 

0
0

3 Answers

50 votes
50 votes
Best answer

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

4 Comments

I think no need of join in option D as both employee name and dept_no is in  same table.

This can be used instead:  projection of name(selection on dept_no = x(emp))

 

3
3
how D option is not correct?
suppose if the name of two employee is same for a given department(x), than we can not get both same name employees, so by this conclusion we can also not get all employee for the given department. please Correct me.
0
0

2nd part of Ans(b) is wrong i.e the query written under OR. There should be another condition that is employee.dept-no=department.dept-no. Also in ans(d) if department no is given as x then we can find  all employees of a given department using employee table only by selecting tuples where dept-no = x and then projecting name

0
0
18 votes
18 votes
aggregate functions are not supported by relational algebra ie. sum,average,maximum,minimum and count.So c is the answer

4 Comments

@ashutoshaay26  what's the output of this query?

0
0
Minimum of table 1 of an attribute c.
1
1

For anyone wondering how min, max can be found out by RA with basic operations.
See https://stackoverflow.com/questions/5493691/how-can-i-find-max-with-relational-algebra.
But sum operation cannot be found out by RA by using just basic operations.

0
0
–5 votes
–5 votes
(b)

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

3 Comments

what about sum?
0
0
edited by
i think with select operator we can calculate sum and sum is not a relation operator

Where can i find the keys of all gate paper ?
0
0
No. sum is an aggregate operator. Simply with select, this cannot be done.
Only keys from 2012 are published. Before that many people have given keys, but they may not be authentic. You can do a google search for this. For 2012-14 you can see here:
http://gatecse.in/wiki/Previous_Year_GATE_Question_Papers_and_Keys
6
6
Answer:

Related questions