Question

QUESTION B1. (7 marks) This question assumes the following relational schema Employee (employeeNumber, lastName, firstName, DOB, HireDate, Position Salary, Dept) Primary Key: employeeNumber Foreign key: Dept refers to DeptID in Department Department (DeptID, DeptName, DeptLocation) Primary Key: DeptID You have been given the following MySQL stored procedure: CREATE PROCEDURE Find_EmployeeName (IN employeeNo INT (11), OUT employeeName VARCHAR (60)) BEGIN SELECT concat(firstName, , lastName) INTO employeeName FROM employees WHERE employeeNumber employeeNo; END (a) (2 marks) Name the two types of parameters that have been used in the declaration of (b) (2 marks) What is a trigger? Explain how triggers can be used to enhance data (c) (3 marks) Create a stored procedure that takes the department name as an input and the procedure Find EmployeeName. List at least one characteristic of each type integrity? prints the details of all the employees who are currently working for the department You may use the following procedure template CREATE PROCEDURE Find_Employee (IN deptName VARCHAR (50)) BEGIN DECLARE empRec CURSOR FOR OPEN empRec; REPEAT END REPEAT; CLOSE empRec; END

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question B1

a) The two types of parameters that have been used in the declaration of the procedure are the IN parameter and the OUT parameter.

    IN parameter:

                   These types of parameters are used to send values to stored procedures. This type of parameter is a read only parameter. We can assign the value of IN type parameter to a variable or use it in a query, but we cannot change its value inside the procedure.

   OUT parameter:

          The OUT parameters are used to send the OUTPUT from a procedure or a function. This is a write-only parameter i.e, we cannot pass values to OUT parameters while executing the stored procedure, but we can assign values to OUT parameter inside the stored procedure and the calling program can receive this output value.

b) A trigger is a procedure that is automatically invoked by the DBMS in response to specified changes to the database.

    Data Integrity: This refers to the accuracy and consistency of data stored in a database, data warehouse, data mart or other construct.

Triggers help to enhance data integrity when there is a referential integrity constraint on the tables or data we are working with and these tables are present in different nodes or servers.

Example: consider a medicine ordering system which contains data from two different servers say server ‘A’ and server ‘B’

Server A contains a database which consists of the tables that store details about the customer orders and the status of order.

Server B contains a database that stored the details about the orders ,products ordered, their availability.

   And suppose a product is not available in the stock then the order that is placed for that product is deleted in the server B. So, when the order is deleted in the server B then the order deletion must also reflect in orders status in the the server A so that the data integrity is maintained.otherwise the customer will be waiting for the completion of that order.So here in such cases we use TRIGGERS to enhance data integrity by creating a trigger that updates the order status in the server A whenever a deletion of order happens in server B.

Add a comment
Know the answer?
Add Answer to:
QUESTION B1. (7 marks) This question assumes the following relational schema Employee (employeeNumber, lastName, firstName, DOB,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED...

    database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...

  • 2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures...

    2. Examine the SQL Script for this test.  Explain the purpose of each of the stored procedures listed below.   Test2SP1 Test2SP2 Test2SP3 Test2SP4 Test2SP5 Test2SP6 DATABASE CODE: if db_id('Test2PremierProducts') is not null begin use master alter database Test2PremierProducts set SINGLE_USER with rollback immediate drop database Test2PremierProducts end create database Test2PremierProducts go USE Test2PremierProducts; go /* create the tables */ CREATE TABLE Rep (RepNum int Identity(10,10), LastName VARCHAR(15), FirstName VARCHAR(15), Street VARCHAR(15), City VARCHAR(15), State VARCHAR(2), Zip VARCHAR(5), Commission MONEY, Rate DECIMAL(3,2),...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT