INF3707 Examination

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

INF3707/OCT

UNIVERSITY EXAMINATIONS

OCTOBER 2024

INF3707

DATABASE DESIGN AND IMPLEMENTATION

Welcome to the INF3707 exam.

Date: 31 October 2024


Time: 08:00
Hours: 2hrs

Examiner name: Dr. B Chipangura


Internal moderator name: Dr. L Motsi
External moderator name: Ms. V Booi

This paper consists of 9 pages and Annexture A with 4 pages (i-iv)

Total marks: 100

Instructions:
• This paper has Annexture A containing the JustLee database tables.
• This is a closed-book exam.
• Answer all questions.
• The marks for each question are given in brackets next to the question.
• Answer the questions in order. If you want to answer a question later, leave a blank space.
• You are not allowed to use mobile devices, calculators, the Internet, or Oracle XE during
this exam.
• Pledge that you have not given or received aid on this examination (You must respond to
this pledge when submitting your assignment.)
• Students are required to use the IRIS invigilator.

Additional student instructions


1. Students must upload their answer scripts in a single PDF file (answer scripts must not be
password protected or uploaded as “read only” files)
2. Incorrect file format and uncollated answer scripts will not be considered.
3. Email scripts will not be accepted.
4. Students are advised to preview submissions (answer scripts) to ensure legibility and that
the correct answer script file has been uploaded.
5. Incorrect answer scripts and/or submissions made on unofficial examination platforms
(including the invigilator cell phone application) will not be marked and no opportunity will
be granted for resubmission. Only the last answer file uploaded within the stipulated
submission duration period will be marked.
6. The mark awarded for incomplete submission will be the student’s final mark. No
opportunity for resubmission will be granted.
7. The mark awarded for illegible scanned submission will be the student’s final mark. No
opportunity for resubmission will be granted.
8. Submissions will only be accepted from registered student accounts.
9. Students who have not used the proctoring tool will be deemed to have transgressed the
Unisa examination rules and will have their marks withheld. If a student is found to have
been outside the proctoring tool for a total of 10 minutes during their examination session,
they will be considered to have violated the Unisa examination rules and their marks will be

[Turn over]

Open Rubric
INF3707/OCT

withheld. For examinations using the IRIS invigilator system, IRIS must be recorded
throughout the duration of the examination until the submission of the examination scripts.
10. Students have 48 hours from the date of their examination to upload their IRIS invigilator
results. Failure to do so will result in students deemed to have not utilised the proctoring
tools.
11. Students suspected of dishonest conduct during the examinations will be subjected to
disciplinary processes. Students may not communicate with any other person or request
assistance from any other person during their examinations. Plagiarism is a violation of
academic integrity and students who plagiarise, copy from published work or Artificial
Intelligence Software (eg ChatGPT) or online sources (eg course material), will be in
violation of the Policy on Academic Integrity and the Student Disciplinary Code and may be
referred to a disciplinary hearing. Unisa has zero tolerance for plagiarism and/or any other
forms of academic dishonesty.
12. Listening to audio (music) and using audio-to-text software is strictly prohibited during your
examination session unless such usage of the software is related to a student’s assistive
device that has been declared. Failure to do so will be a transgression of the Unisa
examination rules, and the student's marks will be withheld.
13. Students have 30 minutes to submit their answer scripts after the official examination time.
Students who experience technical challenges should report the challenges to the SCSC
on 080 000 1870 or their College exam support centres (refer to Get help during the
examinations by contacting the Student Communication Service Centre [unisa.ac.za])
within 30 minutes. Queries received after 30 minutes of the official examination duration
time will not be responded to. Submissions made after the official examination time will be
rejected according to the examination regulations and will not be marked. Only
communication received from your myLife account will be considered.
14. Nonadherence to the processes for uploading examination responses will not qualify the
student for any special concessions or future assessments.
15. Queries that are beyond Unisa’s control include the following: a. Personal network or
service provider issues
b. Load shedding/limited space on a personal computer
c. Crashed computer
d. Non-functioning cameras or web cameras.
e. Using work computers that block access to the myExams site (employer firewall
challenges)
f. Unlicensed software (eg licence expires during exams)
Students experiencing the above challenges are advised to apply for an aegrotat and
submit supporting evidence within ten days of the examination session. Students will not
be able to apply for an aegrotat for a third examination opportunity.
Postgraduate/undergraduate students experiencing the above challenges in their second
examination opportunity will have to reregister for the affected module.
16. Students suspected of dishonest conduct during the examinations will be subjected to
disciplinary processes. UNISA has zero tolerance for plagiarism and/or any other forms of
academic dishonesty.
17. Students experiencing network or load-shedding challenges are advised to apply together
with supporting evidence for an Aegrotat within 3 days of the examination session.

2
[Turn over]
INF3707/OCT

Question 1: Multiple choice questions


• Choose the correct answer. The marks for each question are given in brackets next to the
question.
• Write down the question number and the letter of the correct answer (for example 1. 1 B) in
your examination book.

Question 1.1:
When you code a calculated value in a SELECT clause, the expression for the calculated value can
include which of the following. (2 marks)
A. arithmetic operators only
B. arithmetic operators and functions only
C. arithmetic operators, comparison operators, and functions only
D. arithmetic operators, comparison operators, logical operators,
and functions

Question 1.2:
Assume that the Books table has a column named Cost. Which of the following SELECT clauses
would you use to assign an alias for calculating the total cost of books? (2 marks)
A. SELECT cost LIKE total from Books;
C. SELECT cost AS total from Books;
D. SELECT cost:total from books;
D. SELECT cost(invoice_total) from Books

Question 1.3:
In a join, column names need to be qualified only. (2 marks)
A. in inner joins
B. in outer joins
C. when the code is confusing
D. when the same column names exist in both tables

Question 1.4:
Which of the following statements is not true about the USING keyword? (2 marks)
A. you use it to simplify the syntax for joining tables
B. you code a USING clause in addition to an ON clause
C. it can be used with inner or outer joins
D. the join must be an equijoin

3
[Turn over]
INF3707/OCT

Question 1.5:
Assuming that the table name and the column names are spelled correctly, what is wrong with the
following INSERT statement? (2 marks)
INSERT INTO invoices(vendor_id, invoice_number, invoice_total,
payment_total, credit_total,terms_id, invoice_date, invoice_due_date)
VALUES (97, '456789', 8344.50, 0, 0, 1, '2022-08-31')

A. The column names in the column list are in the wrong


sequence.
B. All of the values should be enclosed by single quotes.
C. There are too many items in the VALUES list.
D. The number of items in the column list doesn’t match the
number in the VALUES list.

Question 1.6
Which of the following clauses are used to suppress duplicates in a SELECT statement? Choose the
best answer. (2 marks)
A. INTERSECT, DISTINCT
B. DUPLICATE, INTERSECT
C. DISTINCT, UNIQUE
D. UNIQUE, INTERSECT

Question 1.7
Determine the output of the query below: (2 marks)

Select (100-25)/15*(20-3)
From dual;
A. 0.294
B. -85
C. 63.67
D. 85

Question1. 8
Which of the following options allow a user to grant system privileges to other users? (2 marks)
A. WITH ADMIN OPTION
B. WITH GRANT OPTION
C. ASSIGN ROLES
D. SET ROLES

Question 1.9
If a PRIMARY KEY constraint named ORDERITEMS_PK exists for the ORDER# and ITEM# columns
of the ORDERITEMS table, which of the following commands will disable the constraints? (2 marks)
a. ALTER TABLE orderitems DISABLE PRIMARY KEY CONSTRAINT
b. ALTER TABLE orderitems DISABLE CONSTRAINT oderitems_pk
c. ALTER TABLE orderitems REMOVE PRIMARY KEY CONSTRAINT
d. ALTER TABLE orderitems MODIFY PRIMARY KEY CONSTRAINT DISABLE

4
[Turn over]
INF3707/OCT

Question 1.10
Examine the structure of the CUSTOMER table created below:

Create table customerX(


Customer# number(4) primary key,
First_name varchar2(25),
Last_name varchar2(25))

Which one of the following insert statements is valid? (2 marks)

A. Insert into customerX values (null, john, ‘smith’);


B. Insert into customerX values (customer#, first_name, last_name) values
(‘john’, ‘smith’);
C. Insert into customerX (first_name, last_name, customer#) values (1000,
‘john’,’smith’);
D. Insert into customerX values (1000, ‘john’, ‘smith’);

Question 1.11
Which four statements are true regarding views? (8 marks)
A. Data can’t be added to a view column containing an expression.
B. Only simple views can use indexes existing on the underlying tables.
C. Both simple and complex views can use indexes existing on the underlying tables.
D. Complex views can be created only on multiple tables that exists in the same schema.
E. Complex views can be created on multiple tables that exist in the same or different
schemas.
F. A row with a view cannot be deleted through a view if the view definition contains the
DISTINCT keyword.
G. If a view is dropped with the DROP VIEW command, the data in the original table will get
affected.
H. DML operations are permitted on non-key-preserved tables.

Question 1.12
You issued the following command:

DROP TABLE BOOKS;

Which three statements are true? (6 marks)


A. All uncommitted transactions are committed.
B. All indexes and constraints defined on the table being dropped are also dropped.
C. Sequences used in the Books table becomes invalid.
D. The space used by the Books table is reclaimed immediately.
E. The Books table can be recovered using the rollback command.
F. The Books table is moved to the recycle bin.

Question 1.13
Which three SQL statements would display the value 2190.55 as $2, 190.55? (3 marks)
A. Select to_char(2190.55,’$0G000D00’) from dual;
B. Select to_char(2190.55, ‘$9,999V99’) from dual;
C. Select to_char(2190.55, ‘$99,999D99’) from dual;
D. Select to_char(2190.55, ‘$99G999V99’) from dual;
E. Select to_char(2190.55, ‘$9,999V99’) from dual;

5
[Turn over]
INF3707/OCT

Question 1.14
You want to create a SALES table with the following column specifications and data types:

• SALESID: Number
• STOREID: Number
• ITEMID: Number
• QTY: Number, should be set to 1 when no value is specified.
• SLSDATE: Date, should be set to current date when no value is
specified.
• PAYMENT: Character up to 30 characters, should be set to CASH when no
value is specified

Which statements would create the table? (5 Marks)


A. CREATE TABLE sales(
salesID NUMBER(4),
storeID NUMBER(4),
itemID NUMBER(4),
qty NUMBER DEFAULT = 1,
slsdate DATE DEFAULT SYSDATE
payment VARCHAR2(30) DEFAULT =
'CASH');

B. CREATE TABLE sales (


salesID NUMBER(4),
storeId NUMBER(4),
itemID NUMBER(4),
qty NUMBER DEFAULT 1,
slsdate DATE DEFAULT SYSDATE,
payment VARCHAR2(30) DEFAULT
'CASH');

C. CREATE TABLE sales(


salesID NUMBER(4),
storieId NUMBER(4),
itemID NUMBER(4),
qty NUMBER DEFAULT 1,
slsdate DATE DEFAULT 'SYSDATE',
payment VARCHAR2(30) DEFAULT
CASH);

D. CREATE TABLE sales(


salesid NUMBER(4),
storieId NUMBER(4),
itemID NUMBER(4),
qty NUMBER DEFAULT= 1,
slsdate DATE DEFAULT SYSDATE,
payment VARCHAR2(30) DEFAULT
= "CASH");

6
[Turn over]
INF3707/OCT

Question 1.15
Which statement adds a constraint that ensures the Lastname column of the CUSTOMERS table of
the JustLee Books database holds a value? (3 marks)

SQL> desc CUSTOMERS;

Name Null? Type


------------ -------- ---------
CUSTOMER# NUMBER(4)
LASTNAME VARCHAR2(10)
FIRSTNAME VARCHAR2(10)
ADDRESS VARCHAR2(20)
CITY VARCHAR2(12)
STATE VARCHAR2(2)
ZIP VARCHAR2(5)
REFERRED NUMBER(4)
REGION CHAR(2)

A. Alter table customers add constraint lastname_nn check customer_name


is not null;
B. Alter table customers modify constraint cust_name_nn check lastname is
not null;
C. Alter table customers modify lastname constratint cust_name_nn not
null;
D. Alter table customers modify last_name constraints cust_name_nn is not
null;

Question 2
John is an Accountant at JustLee Books and require access to the OrderItems table. To provide John
with the access to the database, do the following activities:

Question 2.1
Create an account for John and provide him with a password that expires. (3 marks)

Question 2.2
Provide John with the role of an accountant. (2 marks)

Question 2.3
John should have the rights to grant other employees with access priviledges to the OrderItems table.
(4 marks)

7
[Turn over]
INF3707/OCT

Question 3
Examine the structure of the CUSTOMERS table extracted from the JustLee Books, and answer the
following question.

SQL> desc customers;

Name Null Type


--------- ------ ------------
CUSTOMER# NOT NULL NUMBER(4)
LASTNAME NOT NULL VARCHAR2(10)
FIRSTNAME NOT NULL VARCHAR2(10)
ADDRESS VARCHAR2(20)
CITY VARCHAR2(12)
STATE VARCHAR2(2)
ZIP VARCHAR2(5)
REFERRED NUMBER(4)
REGION CHAR(2)
EMAIL VARCHAR2(30)

Create a query that uses self join to list all cities that have more than one customer, along with the
customer details such as CUSTOMER#, LASTNAME, AND CITY. (6 marks)

Question 4
Determine which books customer Jake Lucas purchased. Perform the search using the
customer’sname, rather than the customer number. If he has purchased multiple copies of the same
book, duplicate the results. Generate the report using the (JOIN…USING) keywords. Refer to
Annexture A for database tables for the JustLee Books. (5 marks)

Question 5
Consider the following table that keeps track of vendors of the JustLee Books. The table contains five
columns: Vendor_id, Vendor_name, Address, Zip_code and Phone.

Column Name Null Type


Vendor_id Number (4)
Vendor_name Not Null Varchar2(30)
Address Varchar2(30)
Zip_code Varchar2(4)
Phone Not Null Varchar2 (10)

Quesion 5.1
Write the SQL code that creates the Vendors database table. (10 marks)

Question 5.2
The Vendor_id column is not currently set as a primary key. Write an SQL query to alter the table and
make Vendor_id the primary key. (3 marks)

Question 5.3
The vendor table does not have columns for capturing the account number and the email of each
vendor. Add the two new columns to the table, Acc_number with a data type VARCHAR2 (10) and
email VARCHAR2 (5). Both these new columns should be Not Null. (6 marks)

8
[Turn over]
INF3707/OCT

Question 5.4
The size of the email coloumn is too small to capture a meaningful email address. Create an SQL
query to enlarge the size from VARCHAR2(5) to VARCHAR(20). (3 marks)

Question 5.5
Insert the following data into the Vendors table. (10 marks)

Vendor_ID Vendor_name address Phone Email


1001 Peter 16 Main Str 07800 [email protected]
1002 John 20 Falcon Str 07900 [email protected]

Question 5.6

Delete the vendor with Vendor_id 1002 from the Vendors table. (3 marks)

The end
© UNISA 2024

9
[Turn over]
i

OCT/NOV 2024 Exam

Annexure A
Describe Customers

Select * from Customer


ii

Describe Orders

Select * from Orders


iii

Describe orderitems

Select * from orderitems


iv

Describe books

Select * from books

The end

© UNISA 2024

You might also like