Given are the following relations: Specify the following queries as relation alg
ID: 3705420 • Letter: G
Question
Given are the following relations:
Specify the following queries as relation algebra expressions:
a) In which locations do the employees live?
b) Issue a list of employee names and salaries.
c) What are the names of the employees who work in projects?
d) The names of the employees who work in the "Data Warehouse" project.
e) What is the name of the employee who manages the intranet project and what is his profession?
f) What are the employees who do not work in projects?
g) For each of the expressions, think of an alternative expression that comes to the same result.
Indicate which term you think could be faster (with justification).
Explanation / Answer
Hi.. Please check below,
Specify the following queries as relation algebra expressions:
a) In which locations do the employees live?
Ans:
select distinct city from Employee;
from the above query we get the list of cities where employees are resides. in above query i have used distinct for remove duplicate names that was already in the list.
b) Issue a list of employee names and salaries.
Ans:
select Name,Salary from Employee;
it list out list of all employee names and salaries.
c) What are the names of the employees who work in projects?
Ans:
select a.Name from Employee a, Emp_programm b where a.Emp_num=b.Pro_num;
In the above we are joining two tables and get the names of employees that are work in projects.
d) The names of the employees who work in the "Data Warehouse" project.
Ans:
select a.Name from Employee a, Emp_programm b where a.Emp_num=b.Pro_num and b.Pro_num in (select c.Pro_num from Project c,Emp_programm d where c.Pro_num=d.Pro_num and c.Name='Datawarehouse');
From the above i have written subquery to get list of project codes and added in where condition.
e) What is the name of the employee who manages the intranet project and what is his profession?
Ans: select a.Name,'Project Manager' from Employee a, Project b where a.Emp_num = b.Proj_manager and b.Name='intranet';
In the above i have joined two tables and get the result.
f) What are the employees who do not work in projects?
Ans: select a.Name from Employee a, Emp_programm b where a.Emp_num<>b.Pro_num;
In the above i have joined two tables and and added not equal condition to the query.
g) For each of the expressions, think of an alternative expression that comes to the same result.
Indicate which term you think could be faster (with justification).
Ans: I have given explanation for each of questions above.
Please check above answers and let me know any querries. Thank you. All the best.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.