1 start with checksalary trigger explain below on triggers

Assignment Help Database Management System
Reference no: EM13350558

1) Start with CHECK_SALARY trigger explain below on triggers. Show that that trigger creates MUTTATING TABLE error. In order to circumvent that problem, write a combination of a BEFORE statement trigger and a modified BEFORE ROW trigger. Use the before statement trigger to record values of v_maxsalary and v_minsalary as packaged variables. In the row trigger perform the needed range check using those packaged variables. Add an AFTER statement trigger that would set those packaged variables to NULL, making it required for the BEFORE statement trigger to fire and act properly for the business rule to be enforced. Show that the above error is not raised. This is a standard way of eliminating mutating table errors.

MutatingTable:Example

SQL>CREATEOR REPLACETRIGGERcheck_salaryBEFOREINSERT OR UPDATEOFsal,job ONempFOREACH ROW

WHEN (new.job<> 'PRESIDENT') DECLARE

v_minsalaryemp.sal%TYPE;

vmaxsalaryemp.sal%TYPE;

BEGIN

SELECT MIN(sal),MAX(sal)

INTO   v_minsalary,v_maxsalary

FROM   emp

WHEREjob= :new.job;

IF:new.sal<v_minsalary OR

:new.sal>v_maxsalaryTHEN RAISE_APPLICATION_ERROR(-20505,

'Out of range');

;

END IF;

END;

SQL>UPDATEemp

SETsal=1500

WHEREename= 'SMITH';

*

ERRORatline2

ORA_4091:TableEMPismutating,trigger/functionmaynotseeit

ORA_06512:atline4                                   

ORA_04088:errorduringexecutionoftrigger'check_salary';

This trigger, CHECK_SALARY, tries to guarantee that whenever a new employee is added to the EMP table or an existing employee's salary or job title is changed, the employee's salary falls within the established salary range for the employee's job

2) Suppose Entity Title on slide below of Lecture note. Implement that entity as a database table with two subtypes, Games and Movie. Let both subtypes have their own unique ids, e.g. movie_id and game_id. Create another entity (table) Rented_Item that records rented items. Let that table reference movies and games from table (entity) Title. Implement the referential integrity using triggers. Populate both tables with various rows and shows that the referential integrity may be maintained.

Reference no: EM13350558

Questions Cloud

Questiona rectangular loop has 85 turns with an area of : questiona rectangular loop has 85 turns with an area of 0.225 m2 and lies in a uniform magnetic field of 0.28 t.
Question1a small immersion heater can be used to heat a cup : question1a small immersion heater can be used to heat a cup of water for coffee or tea. if the heater can heat 180ml
Question1a long solenoid with 70 turns of wire per : question1a long solenoid with 70 turns of wire per centimeter carries a current of 0.16. the wire that makes up
Questionthe executives at cbc want to realise how they are : questionthe executives at cbc want to realise how they are doing in ratings against the other networks as well as how
1 start with checksalary trigger explain below on triggers : 1 start with checksalary trigger explain below on triggers. show that that trigger creates muttating table error. in
Question1if you drop a rock from a height of 71 m it : question1if you drop a rock from a height of 7.1 m it accelerates at g and strikes ground 1.20374 s later.if you drop
Question1a 8kg mass moves in a circular path of 4m radius : question1a 8kg mass moves in a circular path of 4m radius on a frictionless horizontal table. it is attached to a
Questionresearch an article on a current event that centres : questionresearch an article on a current event that centres on some sort of question or controversial issue. then
Question1imagine you are on a planet similar to earth where : question1imagine you are on a planet similar to earth where an acceleration of gravity is approximately 10 ms2.the

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd