1.

Consider The Relational Database Of Figure 4.13. Using Sql, Define A View Consisting Of Manager-name And The Average Salary Of All Employees Who Work For That Manager. Explain Why The Database System Should Not Allow Updates To Be Expressed In Terms Of This View?

Answer»

Answer : create view salinfo as SELECT manager-name, avg(salary) from manages m, works w where m.EMPLOYEE-name = w.employee-name group by manager-name

UPDATES should not be allowed in this view because there is no way to determine how to change the underlying data. For example, suppose the request is “change the average salary of employees working for Smith to $200”. Should everybody who works for Smith have their salary CHANGED to $200? Or should the first (or more, if necessary) employee found who works for Smith have their salary adjusted so that the average is $200?NEITHER approach really makes sense.

Updates should not be allowed in this view because there is no way to determine how to change the underlying data. For example, suppose the request is “change the average salary of employees working for Smith to $200”. Should everybody who works for Smith have their salary changed to $200? Or should the first (or more, if necessary) employee found who works for Smith have their salary adjusted so that the average is $200?Neither approach really makes sense.



Discussion

No Comment Found

Related InterviewSolutions