0% found this document useful (0 votes)
130 views7 pages

INF3707 Examination

Uploaded by

Mduduzi Nzuza
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 (0 votes)
130 views7 pages

INF3707 Examination

Uploaded by

Mduduzi Nzuza
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/ 7

UNIVERSITY EXAMINATIONS

OCT/NOV 2022

INF3707

DATABASE DESIGN AND IMPLEMENTATION

Duration: 2 hours
Total marks: 100

Examiners:
First: Dr B. Chipangura
Second: Dr L. Motsi
External: Dr G. Toko
This is a closed book examination, under IRIS invigilation. Unisa exam policy applies.

Instructions to students
1. Answer all questions in the given order.
2. You are not allowed to use Mobile devices, Calculators or Oracle XE during this exam.
3. Study the tables in Annexure A.
4. Students must upload their answer scripts in a single PDF file (answer scripts must not be
password protected or uploaded as “read only” files.)
5. NO emailed scripts will be accepted.
6. Students are advised to preview submissions (answer scripts) to ensure legibility and that
the correct answer script file has been uploaded.
7. Students are permitted to resubmit their answer scripts should their initial submission be
unsatisfactory.
8. Incorrect file format and uncollated answer scripts will not be considered.
9. Incorrect answer scripts and/or submissions made on unofficial examinations platforms
(including the invigilator cellphone application) will not be marked and no opportunity will
be granted for resubmission.
10. Mark awarded for incomplete submission will be the student’s final mark. No opportunity
for resubmission will be granted.
11. Mark awarded for illegible scanned submission will be the student’s final mark. No
opportunity for resubmission will be granted.
12. Submissions will only be accepted from registered student accounts.
13. Students who have not utilised the IRIS invigilation tools will be subjected to disciplinary
processes.
14. Students suspected of dishonest conduct during the examinations will be subjected to
disciplinary processes. UNISA has a zero tolerance for plagiarism and/or any other forms
of academic dishonesty.
15. Students are provided 30 minutes to submit their answer scripts after the official
examination time. Submissions made after the official examination time will be rejected by
the examination regulations and will not be marked.
16. 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.

Students experiencing technical challenges, contact the SCSC 080 000 1870 or email
[email protected] or refer to Get-Help for the list of additional contact numbers.

[Turn over]

Open Rubric
2 INF3707
OCT/NOV

Question 1 20 marks
Choose the most applicable answers and write in your on your answer sheet. For example, 1.1 A,B, C,D

1.1 Which four(4) statements are true regarding views? (4 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. Row on 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

1.2 Examine the data in the Orderitems tables (2 marks)

ORDER# ITEM# QUANTITY


---------- ---------- ----------------
1007 2 1
1007 3 1
1007 4 1
1008 1 2
1009 1 1
Evaluate the following query:

select item#, avg(quantity) from orderitems having avg(quantity) >


min(quantity)*0.5 group by item#;

Which statement is true regarding the outcome of the above query?


A. It gives an error because the having clause should be specified after the GROUP BY clause
B. It gives an error because all the aggregate functions used in the HAVING clause must be specified in the
SELECT list.
C. It displays the item numbers with their average quantity where the average quantity is more than 0.5 the
minimum quantity of that item in the table
D. It displays the item numbers with their average quantity where the average quantity is more than 0.5 the
overall quantity of the items in the table.

1.3 Which three (3) SQL statements would display the value 2190.55 as $1, 890.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;

1.4 If a column has high selectivity or cardinality, which index type is most appropriate for that column?
(2 marks)
A. IOT
B. B-tree
C. Bitmap
D. Function based index

[Turn over]
3 INF3707
OCT/NOV

1.5 Which statement adds a constraint that ensures the LASTNAME column of the CUSTOMERS table of the
JustLee Books database holds a value? See structure of CUSTOMERS below. (2 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;

1.6 Which of the following keywords must have been included during the creation of a FOREIGN KEY constraint
to allow a row from the parent table to be deleted, even if it is referenced by a row in the child table? (1 mark)

A. CASCADE
B. AUTO REMOVE
C. ON DELETE CASCADE
D. NONE OF THE ABOVE

1.7 You issued the following command:

DROP TABLE BOOKS;

Which three(3) statements are true? (3 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

[Turn over]
4 INF3707
OCT/NOV

1.8 Evaluate the SQL statement:

TRUNCATE TABLE BOOKS;

Which of the following three(3) statements are true about the SQL statement. (3 marks)
A. It releases the storage space used by the table
B. It does not release the storage space used by the table
C. You can roll back the deletion of rows after the statement executes
D. You cannot roll back the deletion of rows after the statement executes
E. An attempt to use DESCRIBE on the BOOKS table after the TRUNCATE statement executes will
display an error
F. You must be the owner of the table or have DELETE ANY TABLE system privilege to truncate the
BOOKS table.

Question 2 30 Marks
2.1 The following SQL code creates a table that keeps record of food products and checks for their
expiry dates.

CREATE TABLE Stock


(stock_no# NUMBER (4) NOT NULL,
expiry_date date CHECK (expiry_date > SYSDATE),
CONSTRAINT its_pky PRIMARY KEY (stock_no#)
);

When you run the code, it gives an error.


i. What caused the rror? (2 marks)
ii. Rewrite the code to correct the error. (3 marks)

2.2 Examine the structure of the MyCustomer01 table:

Create table MyCustomer01(


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

Create an SQL statement to insert the following data into the MyCustomer01 table (customer# is
1000; First_name is John; Last_name is Smith). (4 marks)

2.3 The Database Administrator wants to grant all users with query privileges on the MyCustomer01
table. Write an SQL statement that accomplishes this? (2 marks)
2.4 What does the following query do? Describe the output. (2 marks)

SELECT isbn, title


FROM books
WHERE (pubid, category) IN
(SELECT pubid, category
FROM books WHERE title LIKE ‘%ORACLE%’);

[Turn over]
5 INF3707
OCT/NOV

2.5 Examine the contents of the PUBLISHER table.


PUBID NAME CONTACT PHONE
---------- -------------- --------------- - -----------
1 PRINTING IS US TOMMIE SEYMOUR 000-714-8321
2 PUBLISH OUR WAY JANE TOMLIN 010-410-0010
3 AMERICAN PUBLISHING DAVID DAVIDSON 800-555-1211
4 READING MATERIALS INC. RENEE SMITH 800-555-9743
5 REED-N-RITE SEBASTIAN JONES 800-555-8284

Write a query that lists only the last four digits of the contact person's phone number at Publish Our
Way? (3 marks)

2.6 Based on the data extracted from the BOOKS table of the JustLee database, see table below, write
a query that displays 5 percent of the books with the highest retail price. (4 marks)

ISBN TITLE RETAIL


1059831198, BODYBUILD IN 10 MINUTES A DAY 30.95
0401140733 REVENGE OF MICKEY 22
4981341710 BUILDING A CAR WITH TOOTHPICKS 59.95
8843172113 DATABASE IMPLEMENTATION 55.95
3437212490 COOKING WITH MUSHROOMS 19.95

2.7 Examine the structure of the ORDERS table of the Justlee Books given below.

Name Null? Type


--------------------- -------- ---------------------- ----
ORDER# NOT NULL NUMBER(4) --
CUSTOMER# NUMBER(4)
ORDERDATE NOT NULL DATE
SHIPDATE DATE
SHIPSTREET VARCHAR2(18)
SHIPCITY VARCHAR2(15)
SHIPSTATE VARCHAR2(2)
SHIPZIP VARCHAR2(5)
SHIPCOST NUMBER(4,2)

Based on the ORDERS table of the JustLee Books database, you want to find the value of the
total shipment of all the orders for each year and you issue the following command:

SELECT to_char(orderdate, 'rr'),sum(shipcost)


FROM orders
GROUP by to_char(orderdate,'YY');

When you execute this piece of code it gives an error.

(i) What causes the error? (2 marks)


(ii) Write the debugged piece of code (4 marks)
[Turn over]
6 INF3707
OCT/NOV

2.8 Examine the data extracted from the CUSTOMERS table of the JustLee books database, see table
below.

CUSTOMER# LASTNAME REFERRED


---------- ---------- ----------
1012 MCKENZIE
1013 NGUYEN 1006
1014 LEE
1015 SCHELL
1016 DAUM 1010
1017 NELSON
1018 MONTIASA
1019 SMITH 1003

Write a query to determine the total number of customers who were referred by other customers?
(4 marks)

Question 3 30 marks

3. 1 Create the following table. (10 marks)

Table Name: MyCustomers03

NAME NULL TYPE


-------- ------ ---------
myCUSTOMER# NUMBER (4)
myLASTNAME NOT NULL VARCHAR2(10)
myFIRSTNAME NOT NULL VARCHAR2(10)
myADDRESS VARCHAR2(20)
myCITY VARCHAR2(20)
myZIP VARCHAR2(5)

3.2 The MyCustomers03 table does not have a primary key, make CUSTOMER# the primary key.
(5 marks)

3.3 Insert data into the MyCustomers03 table based on the columns of the CUSTOMERS table of the
JustLee Books, see Annexture A for table structure of the CUSTOMERS table. (6 marks)

3.4 The MyCustomers03 table does not have the columns for capturing the client’s e_mail address as
well as the the Province. Add the two columns to the MyCustomers03 table. (5 marks)

3.5 Create a bitmap index and name it my_customers_state_idx on the MyCustomers03 table to
speed up queries for searching customers based on their province of residence. Verify that the index is
created and then delete the index. (4 marks)

[Turn over]
7 INF3707
OCT/NOV

Question 4 20 marks
4.1 Determine which books customer Jake Lucas purchased. Perform the search using the customer name, not 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 the tables in Annexure A. (5 marks)

4.2 Determine the total profit generated by the book purchased on order 1002. Display the book title and profit.
The profit should be formatted to display a dollar sign and two decimal places. Consider that the customer might
not pay the full retail price and each item ordered can involve multiple copies. Refer to the tables in Annexure A.
(5 marks)

4.3 Determine which books were shipped to the same state as order 1014. Use subqueries to answer the question.
Refer to the tables in Annexure A. (5 marks)

4.4 Determine the total profit generated by sale to customer 1017. Note that quantity should be reflected in the
profit calculation. Refer to the tables in Annexure A. (5 marks)

The End
©
UNISA

You might also like