0% found this document useful (1 vote)
57 views3 pages

Itu 07301 2020-2021 Se 2021 PDF

This document contains a database exam on database technologies with 5 questions. It includes sample database tables for a broker firm (crop, cropVariant, stockRecord). Question 1 has SQL queries on the DML operations and modifying the tables. Question 2 contains queries selecting, updating, deleting records. Question 3 involves relationships between tables and generating a report. Question 4 contains queries combining tables and counting records. Question 5 covers stored procedures, triggers, and creating a trigger to log deleted records from stockRecord to the audit table stockAudit.

Uploaded by

mike akim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
57 views3 pages

Itu 07301 2020-2021 Se 2021 PDF

This document contains a database exam on database technologies with 5 questions. It includes sample database tables for a broker firm (crop, cropVariant, stockRecord). Question 1 has SQL queries on the DML operations and modifying the tables. Question 2 contains queries selecting, updating, deleting records. Question 3 involves relationships between tables and generating a report. Question 4 contains queries combining tables and counting records. Question 5 covers stored procedures, triggers, and creating a trigger to log deleted records from stockRecord to the audit table stockAudit.

Uploaded by

mike akim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NATIONAL INSTITUTE OF TRANSPORT (NIT)

DEPARTMENT OF COMPUTING AND COMMUNICATION TECHNOLOGY (CCT)


HIGHER DIPLOMA TWO IN INFORMATION TECHNOLOGY (HDIT-2)
HIGHER DIPLOMA TWO IN COMPUTER SCIENCE (HDCS-2)

FIRST SEMESTER EXAMINATIONS; 2020/2021

MODULE NAME: DATABASE TECHNOLOGIES WEDNESDAY 10TH MARCH 2021


MODULE CODE: ITU 07301 TIME: 3HRS

Answer all Questions

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)

QUESTION TWO (20 MARKS)


a). With respect to the database tables, differentiate a primary key from foreign key (4 Marks)
b). What will be the effect of writing SQL update statement on a table without a WHERE clause? (2 Marks)
c). List using BETWEEN keyword all cropVariant with available stock ranging from 400 to 7200
inclusively. (4 Marks)
d). Write SQL statement to change the cropID of Korosho to new333. (3 Marks)
e). Write SQL statement to remove all stockRecord with amount ranging from 210 and 360 exclusively.
(4 Marks)
f). From the cropVariant table, write SQL statement to answer the question how many crops have variants?
(3 Marks)
QUESTION THREE (20 MARKS)
a). As it seen from the snapshot of the tables above, stockRecord.varID is a foreign key referencing
cropVariant.varID. Explain the domain of these two attributes/columns. (2 Marks)
b). Write SQL statement to generate a report containing cropName (Jina la Zao), varName (Aina ya Zao),
availableStock (Kiwango Kilichopo) and oppDate (Tarehe ya Kupokea) for all cropVariant with
availableStock less than 300. Your report should contain Swahili heading as shown in the brackets. Display
only the 12 records skipping the first 65 records. Sort your report in the descending order of availableStock
(8 Marks)
c). Based on the set of data shown above, sketch the output of the following SQL statement (8 Marks)
SELECT cropVariant.varID, cropVariant.varName FROM cropVariant WHERE cropVariant.varName
LIKE “N%” ORDER BY cropVariant.cropID DESC, cropVariant.varID;

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)

QUESTION FIVE (25 MARKS)


a). How does a stored procedure differ from trigger in terms of their invocation? (3 Marks)
b). List two disadvantages of using triggers in your application. (2 Marks)
c). Write a procedure called variantStockRecords that will list all details in the stockRecord table after
receiving a variant ID (varID) (10 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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy