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.
QUESTION B1. (7 marks) This question assumes the following relational schema Employee (employeeNumber, lastName, firstName, DOB,...
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 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),...