Itu 07301 2020-2021 Se 2021 PDF
Itu 07301 2020-2021 Se 2021 PDF
The following three tables represent a current state of a database called brokerCompany used by a small
scaled broker firm to keep records of its activity. They can be used in answering the examination questions
whenever necessary.
Page 1 of 3
QUESTION ONE (20 MARKS)
a). What are the four operations that a DML statement can do? (2 Marks)
b). What will the statement delimiter @@ do? (2 Marks)
c). Write SQL statement to display structure of the stockRecord table and SQL statement to show the create
table statement of the cropVariant table. (2 Marks)
d). Write SQL statement that will remove the column called availableStock from the cropVariant table.
(3 Marks)
e). Write SQL statement that will add a column named receiver in the stockRecord table. That column
should be placed in the beginning. The column is a required one with default value of Owner. (5 Marks)
f). Write a single SQL statement that will insert the last two rows of the crop table at once. (4 Marks)
g). Write SQL statement to rename the table cropVariant to mazaoAina. (2 Marks)
d). Write a DDL statement that will remove all data from the crop table (2 Marks)
Page 2 of 3
QUESTION FOUR (15 MARKS)
a). Write SQL statement that will produce a report containing all details of the crop table for all crop that
were recorded in the stock with OUT opptype and amount above 1350.00. (5 Marks)
b). Write SQL statement that will list from stockRecord table the cropID and varID for all crop variant
that were recorded more than five times. (5 Marks)
c). How does SQL DELETE differ from SQL DROP? (5 Marks)
d). Given the following table as audit table for the live table stockRecord (10 Marks)
create table stockAudit(
sn int auto_increment primary key,
cropID varchar(50) not null,
varID varchar(50) not null,
stockID varchar(50) not null,
oppType varchar(50) not null,
oppDate date not null,
amount decimal(12,2) not null,
changeDate DateTime not null,
changeReason varchar(50) not null,
changer varchar(50) not null );
Create a DELETE trigger that will log the information about deleted record of the table stockRecord into
the table stockAudit. The column changer should record a value Admin while changeReason will be
delete and changeDate should read time and date from the server.
Page 3 of 3