Jan 2022
Jan 2022
January/February 2022
INF3707
Examiners:
First: Dr B. Chipangura
Second: Dr L. Motsi
External: Dr P. Nkomo
Instructions to students
1. Unisa examination policies apply.
2. Answer all questions.
3. Study the tables and data in Annexure A.
4. The marks for each question are given in brackets next to the question.
5. Please answer the questions in order. If you want to do a question later, leave a blank
space.
6. Pocket calculators are not allowed.
7. Pledge that you have neither given nor received aid on this examination (You must respond
to this pledge when submitting your assignment.)
8. After writing the exam, upload your answer sheet in PDF format on myUnisa as per
instructions provided to you in Exam Tutorial letter. Do not add any other form of
protection on your document. Incorrect file formats or unreadable files will be assigned a
zero mark.
9. Students who do not submit their answer sheets within the scheduled session time will be
marked as absent. Those who could not participate in the examination must formally apply
for an aegrotat opportunity. This rule also applies to students who may be affected by load
shedding. You should supply sufficient evidence in an application for an aegrotat due to load
shedding. Note that supplementary students do not qualify for an aegrotat regardless of the
circumstances.
10. You are not allowed to copy any text from the textbook or slides; other students’ notes or
answers; templates, memos or example answers from any previous assignments, online
tutors, the internet, or any other sources. All questions must be answered in your own,
original words. All scripts will be put through a plagiarism checking tool. Cases, where
copying and pasting, patchwriting, plagiarism, collaboration or other authenticity issues are
suspected, will receive a zero mark and the cases will be reported to the Student Disciplinary
Section in DSAA for disciplinary action.
[Turn over]
Open Rubric
2 INF3707
Jan/Feb
Question 1 20 Marks
For each question, select the correct answer and write it on your answer sheet. Each question carries 2
marks
1.1. Which of the following is an interface that allows a user to create, edit, and manipulate data on
Oracle Database management System?
1. SQL
2. SQL* plus
3. ASCII
4. Database
1.2. Based on the Justlee books database (Annexure A), which of the following SELECT statements
display a list of customer names from the CUSTOMERS table?
1. Select customer names from customers;
2. Select names from customers;
3. Select firstname, lastname from customers;
4. Select first_name, last_name from customers;
1.3. Which of the following symbols is used for a column alias containing spaces?
1. Single quotation marks (' ')
2. Pipe (| |)
3. Double quotation marks (" ")
4. Percentage signs (% %)
1.4. Which of the following will display the new retail price of each book of the Justlee books database
(Annexure A), as 10% less the original retail price?
1. Select title, retail – 10% from books
2. Select retail – 10/100 from books
3. Select retail – 0.1*retail from books
4. Select retail, retail*1.10 from books
1.6. If a PRIMARY KEY constraint named myTable_PK exists for the Col1# and Col2# columns of the
myTable table, which of the following commands will disable the constraint?
1. Alter table myTable disable primary key constraint;
2. Alter table myTable disable constraint myTable_PK;
3. Alter table myTable remove primary key constraint;
4. Alter table myTable modify primary key constraint disable;
[Turn over]
3 INF3707
Jan/Feb
1.7. Which of the following commands will increase the size of the col1 column of the myTable from 12
to 20?
1. Alter table myTable modify (col1 VARCHAR2(+8));
2. Alter table myTable modify (col1 VARCHAR2(20));
3. Alter table myTable modify (col1 (+8));
4. Alter table myTable modify (col1 (20));
1.8. Assuming the myTable table has three columns, col1, col2, col3, in this order, which one of the
following commands store a Null value in col3 of the myTable table?
1. Insert into myTable values (‘A’, ‘B’, ‘C’);
2. Insert into myTable (col1, col2, col3) values (null, ‘A’, ‘B’);
3. Insert into myTable (col1, col2, col3) values (‘A’,’B’, null);
4. Update myTable set col1= col3;
1.9. Examine the structure of the ORDERITEMS and the BOOKS tables given below:
Which of the following commands will make certain that the ISBN entered in the ORDERITEMS table
actually exists in the ISBN column of the BOOKS table?
1. ALTER TABLE orderitems ADD FOREIGN KEY isbn REFERENCES books table (isbn);
2. ALTER TABLE orderitems MODIFY FOREIGN KEY (isbn) REFERENCES books(isbn);
[Turn over]
4 INF3707
Jan/Feb
When you execute the sequence it generate numbers upto a maximum of 200. After issuing the
following SQL statement:
Question 2 15 marks
2.1 After successfully installing an Oracle database, how do you view the available databases on the DBMS?
Write the SQL*plus command to achieve that. (2 marks)
2.2 Oracle Database 18c XE comes with a sample database user named HR. This user owns several database
tables in a sample schema for a fictional Human Resources department. However, for security reasons, this user's
account is locked. You need to unlock this account before you can view the HR objects or build any applications
that use these objects. Assume that you are logged in as Systems Administrator, provide the SQL*plus
commands for unlocking the HR account, making sure that the password reuse and life time is unlimited.
(4 marks)
2.3 John is an Accountant at JustLee Books and require access to the OrderItems table. Create an account for
John and provide him with a password that expire. Make sure that John has a role of an accountant. As an
Accountant, John should have the rights to provide other employees access priviledges to the OrderItems table.
(9 marks)
Question 3 30 marks
Assume that the following table named myCustomers exist in your database and has three columns Col#, Col1,
Col2.
3.2 Write SQL code to check if the table containts any data. (2 marks)
3.3 Verify the existance of the myCustomers table in the data dictionary. (3 marks)
3.4 myCustomers table does not have a primary key, make Col# column the primary key and name the constraint
SA_Customer_pk. (3 marks)
[Turn over]
5 INF3707
Jan/Feb
3.5 myCustomers table contains some columns that are marked as unused. Write an SQL code that drops all the
columns marked as unused. (2 marks)
3.6 All the data entered into myCustomers is not correct. Write an SQL code that deletes the data from the table
but leaving it intact. (2 marks)
3.7 You realised that Col1 and Col2 are too small to accommodate large variables, write an SQL code that
increases the size of Col1 from 2 to 25 and Col2 from 10 to 25. (4 marks)
3.8 Create two more columns (Col3 and Col4) of VARCHAR2() type that can accomodate data with length of
upto 25 character (4 marks)
3.9 Insert data into three columns of myCustomers, by populating Col1, Col3 and Col4 with values A, B and D
in that order. Do not insert any data into Col2, store a null value. (4 marks)
3.10 If the primary key of this table was created with the following statement:
Col# Number GENERATED AS IDENTITY PRIMARY KEY; What output do you expect after inserting
the following data into myCustomers table? Explain your answer.
Insert into MyCustomers (Col#, Col1, Col2, Col3, Col4) values (001, ‘A’, ‘B’,
‘C’,’D’); (4 marks)
Question 4 35 marks
4.1 Create a view that selects every book in the Books table of the JustLee Database (Annexture A) with a retail
price higher than the average retail price of all the books. Name the View Books_Above_Average_Price
and check the data in the view. (10 marks)
4.2 Refer to tables in the JustLeee Books database (Annexxture A) and produce a list of all customers who live
in the state of Florida and have ordered books about computers. (10 marks)
4.3 Display a list of all book titles and percentage of mark-up for each book in the JustLee Books Database
(Annexture A). The percentage of mark-up should be displayed as a whole number (that is, multiplied by 100)
with no decimal position, followed by a percent sign (for example, 0.2793 = 28%). The percentage of mark-up
should reflect the difference between the retail and cost amounts as a percent of the cost.). (5 marks)
4.4 Use subqueries to determine the number of different customers who have placed an order for books written
or co-authored by James Austin. (10 marks)
The end
©
UNISA