DPT621S - DATABASE PROGRAMMING AND TECHNIQUES Theory - 2nd OPP - JAN 2020


DPT621S - DATABASE PROGRAMMING AND TECHNIQUES Theory - 2nd OPP - JAN 2020



1 Page 1

▲back to top


NAMIBIA UNIVERSITY
OF SCIENCE AND TECHNOLOGY
FACULTY OF COMPUTING AND INFORMATICS
DEPARTMENT OF COMPUTER SCIENCE
QUALIFICATION: BACHELOR OF COMPUTER SCIENCE
QUALIFICATION CODE: 07BACS
COURSE: DATABASE PROGRAMMING AND TECHNIQUES
DATE: JANUARY 2020
DURATION: 1HOUR
LEVEL: 6
COURSE CODE: DPT621S
SESSION: 1 (Theory)
MARKS: 30
SECOND OPPORTUNITY/SUPPLEMENTARY EXAMINATION QUESTION PAPER
EXAMINER(S)
MR GEREON KOCH KAPUIRE
MODERATOR
PROF. JOSE QUENUM
THIS QUESTION PAPER CONSISTS OF 4 PAGES
(Including this front page)
INSTRUCTIONS
1.
Answer all questions.
2.
When writing take the following into account: The style should inform more than
impress. It should be formal, in third person, paragraphs set out according to ideas or
issues and the paragraphs flowing ina logical order. Information provided should be
brief and accurate.
3.
Please, ensure that your writing is legible, neat and presentable.

2 Page 2

▲back to top


Section A — Theory (30 Marks)
Question 1
Choose True or False
[10 Marks]
No
Questions
1
Database Programmers design techniques to audit the data
2
Analytical thinking is more important than critical thinking as
a key skill of a Database Programmer .
3
A trigger is a stored procedure that runs automatically when
an event takes place
;
4
Procedures can be called manually
5
Procedures can take input parameters but cannot return
values
6
Both a trigger and stored procedure are called directly by a
user
7
Each transaction is explicitly started with the AS
TRANSACTION
i.
8
Rollback statement will rollback the insert statement as well
as created table
9
Primary data file constructs a SQL Server database
10 | The ALTER PROCEDURE statement creates a trigger
True (T)
False (F)
Question 2
[4 Marks]
Compare and explain the difference between the following two statements.
Statement 1:
CREATE PROCEDURE Pets_Dog
AS
BEGIN
CREATE TABLE Pets(TypelD INT, Type varchar(10))
END
EXECUTE Pets_Dog
SELECT * from Pets
Statement 2:
CREATE PROCEDURE Pets_Dog
AS
BEGIN
CREATE TABLE Pets(TypelD INT,Type varchar(10))
EXECUTE Pets Dog
SELECT * from Pets
END

3 Page 3

▲back to top


Question 3
[2 Marks]
Consider the procedure below. Will the procedure execute successfully? If your answer
is yes, what will the output be? And if it is no, why?
CREATE PROCEDURE NewType
AS
DECLARE @NewType varchar(10)
SELECT @NewType = SUBSTRING(CONCAT('Dog','is','my', 'friend'), 5, 2);
PRINT @NewType
EXECUTE NewType
Question 4
Please explain the difference between the two statements below.
Statement 1:
DISABLE trigger ALL ON ALL SERVER
Statement 2:
DROP Trigger AfterAudit
[4 Marks]
Question 5
[2 Marks]
Consider the information from the table PASS below (please take note that statement 1
is executed already). Can you please show how the result will be when statement 2 is
executed?
.
Statement 1:
CREATE TABLE PASS(
username varchar(20),
password varchar(20))
insert into pass values (‘Test', '123')
insert into pass values (‘Admin’, '321')
Statement 2:
DECLARE @counter INT = 1;
WHILE @counter <= 2
BEGIN
SELECT password from PASS WHERE password =12345 FOR XML RAW
SET @counter = @counter + 1;
SELECT password fram PASS WHERE password =12345 FOR XML PATH
SET @counter = @counter- 1;
END
So
;
Question 6
What will the output be for the statement below?
[2 Marks]

4 Page 4

▲back to top


DECLARE @counter INT = 1;
WHILE @counter <=5
BEGIN
SET @counter = @counter + 1;
PRINT @counter;
SET @counter = @counter + 1;
END
Question 7
Please explain the code below.
[4 Marks]
CREATE PROCEDURE Password_Test
AS
DECLARE @password INT = 123
IF (@password != 123)
SELECT * from LOGIN where PASSWORD
ELSE
SELECT * from LOGIN where PASSWORD
= 123
!= 4
Question 8
[2 Marks]
What is the difference between BEGIN TRANSACTION and COMMIT TRANSACTION?
<<<<<<End of Exam >>>>>