Inf3707 2018 10 e 1

You might also like

Download as pdf
Download as pdf
You are on page 1of 14
UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS UNISA less. INF3707 October/November 2018 Database Design and Implementation Duration — 2 Hours 100 Marks EXAMINATION PANEL AS APPOINTED BY THE DEPARTMENT Closed book examination ‘This examination question paper remains the property of the University of South Africa and may not be removed from the examination venue ‘This paper consists of 7 pages plus an Annexure with vi(7) pages INSTRUCTIONS All rough work must be done in the answer book ‘The marks for each question are given in brackets next to the question Please answer the questions in order If you want to do a question later, leave @ blank space Study the tables and data in Annexure A This 1s not an open book examination Pocket calculators are not allowed Answer all questions [Turn over} 2 INF3707 OCTINOV 2018 Section A: Multiple choice questions [30 marks] + Choose the correct answer © Each correct answer carries 2 marks ‘* Wnte down the question number and the letter of the correct answers or an answer (for example 1 B) in your examination book Question 4 11 Which of the following clauses are used to suppress duplicates in a SELECT statement? Choose the best answer INTERSECT, DISTINCT DUPLICATE, INTERSECT UNIQUE, INTERSECT DISTINCT, UNIQUE vooy 12 Determine the output of the query below Select (100-25) /15*(20-3) from dual 85 0 294 -85 63 67 com> 1.3 Which of the following statements are correct about the WHERE clause? A Column Alias can be used in WHERE clause to refer a column B_ Functions can be used as operands in the WHERE clause C Companson operator 1s an optional element in WHERE clause condition D There can be multiple WHERE clause ina SELECT query [Turn over} 3 INF3707 OCTINOV 2018 1.4 Which of the following 1s true about the SQL query given below? Select coll, col2 From tabl Where coll = 'A‘ Order by col2 DESC, coll, A. Itwull display the row which has the colt value as’A' ordered by the col1 in the descending order and then col? in the descending order B_ The ORDER BY clause will not work as the keyword DESC should be always written in the end of the ORDER BY clause and not in between as given in the query C The above query will be sorted in descending order on the basis of col2 only and the use of col1 in the ORDER BY clause will be discarded D It will display the row which has the col1 value as 'A' ordered by the col1 and then followed by col2 as the execution of the ORDER BY clause happens from the order of columns in the SELECT statement 1.5 What does the following query do? Select isbn, title rom BOOKS where (pubzd, category) IN (select pubid,category from BOOKS where title like 'SORACLES') A. Itdetermines which publisher published a book belonging to the Oracle category and then lists all other books published by that same publisher B Ithists all publishers and categories containing the value of ORACLE C None of the above The query contains a multiple-row operator and because the inner query returns only one value, the SELECT statement will fail and return an error message D Itlists the ISBN and title of all books belonging to the same category and having the same publisher as any book wtth the phrase ORACLE 1n tts title [Turn over] 4 INF3707 OCTINOV 2018 1.6 Refer to the table given below to answer the following questions COMPUTERS 3 sess INC CAST ORT 2 Mess call ATARI i ‘wot vat 10 £08 : Fonretoube SwaRILSt POLIS : Which of the following SQL statements will display the profit generated by each book stored in the BOOKS tables A, Select title, retail, cost From books B. Select title, retail-cost From books C. Select pubid, cost, retail from books D. All of the above 1.7 Which type of a join 1s used in the following statement? select title, order#, quantity from BOOKS full join ORDERITEMS on BOOKS.ISBN = ORDERITEMS ISBN A equality B selfjon C non-equality D. none of the above 4.8 Which of the following displays a list of all system privileges available in Oracle? A SESSION_PRIVS B. SYS-PRIVILEGE_MAP C. V§SYSTEM_PRIVILEGES D. SYSTEM _PRIVILEGE_MAP 1.9 Which of the following options allow a user to grant system privileges to other users? A. WITH ADMIN OPTION B. WITH GRANT OPTION C. ASSIGN ROLES D SET ROLES [Tum over} 5 INF3707 OCTINOV 2018 1 10 Which of the following commands changes a table’s name from OLDNAME to NEWNAME? RENAME oldname TO newname REMANE table FROM oldname TO newname ALTER TABLE oldname MODIFY TO newname CREATE TABLE newname (SELECT * FROM oldname) vow 111 Ifa 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 constraint? A ALTER TABLE orderitems DISABLE PRIMARY KEY CONSTRAINT B ALTER TABLE orderitems DISABLE CONSTRAINT orderitems_pk, © ALTER TABLE orderatems REMOVE PRIMARY KEY CONSTRAINT, D ALTER TABLE orderatems MODIFY PRIMARY KEY CONSTRAINT DISABLE, 112. Which of the following commands is used to add data to an existing row ina table? A ADD B UPDATE C. INSERT D. MODIFY 113 Which of the following commands is used to create a function-based index? A CREATE FUNCTION INDEX . ON B CREATE INDEX .ON © CREATE INDEX . FOR D CREATE INDEX .. FUNCTION 1.14. Which command will delete a user account from a database? DELETE USER username DELETE USER username IDENTIFIED BY password DROP USER username IDENTIFIED BY password DROP USER username; vou» 115 (fa SELECT statement has WHERE, GROUP BY and HAVING clauses, what is the order in which they are processed? A HAVING, WHERE, GROUP BY B WHERE, GROUP BY, HAVING © WHERE, HAVING, GROUP BY D GROUP BY,WHERE, HAVING Question 2 ~~ [30 marks} 2.1 Use search pattern to find any book title with "A" for the second letter and “N" for the fourth letter List each book's ISBN and title Sort the list by title in descending order (4 marks) (Tum over] 6 INF3707 OCTINOV 2018 2.2 Determine the average retat! price of Books by publisher name and category Include only the categories Children and Computer, and the groups with an average retail price greater than $50 Use the keywords JOIN ---USING () (6 marks) 2.3 List the book title and retail price for all books with a retail price lower than the average retail price of all the books sold by JustLee Books Use subquenes (4 marks) 2 4 Create a view that list the name and phone number of the contact person at each publisher Don't include the publisher's ID in the view Name the view CONTACT (3 marks) 2.5 Change the CONTACT view so that no users can accidentally perform DML operations on the view (3 marks) 2.6 Based on the tables of the JustLee books database, determine the profit of each book sold to Jake Lucas using the actual price paid by the customer (not the book's regular price) Sort the results by order date If more than one book was ordered, sort the results by profit amount in descending order Perform the search using customer name, not the customer number Create the query using the keywords JOIN . USING (} (10 marks) ‘Question 3 140 marks] This question refers to Annexure A, the JustLee Books database Learning form the ER diagram and the contents of the BOOKS table, the contents of the Category column are the actual names for each category of books This structure presents a problem if one user enters ‘COMPUTER for the Computer category and another user enters COMPUTERS To avoid this. and other problems that might occur, the database designers have decided to create a CATEGORY table contaming a code (CATCODE) and description (CATDESC) for each category The structure for CATEGORY table should be as follows Table name CATEGORY ‘Column Name Datatype Width ‘CATCODE VARCHAR? 3 _| CATDESC VARCHAR2 i ce Here are some data entries for the CATEGORY table CATCODE CATDESC BUS BUSINESS. ‘CHN CHILDREN. ‘COK COOKING: COM COMPUTER 31 Create the CATEGORY table (3marks) 3.2 The table that you have created does not have a pnmary key, make the column CATCODE the primary key of the table (3 marks) 3.3 The CATDESC column can accept null values, add a constraint to ensure that it does not allow null values (2marks) (Turn over] 7 INF3707, OCTINOV 2018 3.4 Modify the CATDESC column from the current width of 11 characters to 20 characters (2 marks) 3.5 Populate the Category table with the given data Save the changes permanently (8 marks) 3.6 Add a column to the BOOKS table called Catcode Add a FOREIGN KEY constraint that requires all category codes entered in the BOOKS table to already exist in the CATEGORY table (4 marks) 37 Set the CATCODE values for the rows in the BOOKS table based on each book's current Category value (8 marks) 38 Ventfy that the correct categories have been assigned in the BOOKS table, and save changes permanently (4 marks) 3.9 Delete the Category column from the BOOKS table (2 marks) 3.10 Jabulant 1s a newly appointed trainee in the database administration department As the manager of the department, create the user Jabulani, with a password that expire and give him access to the CATEGORY table Assign him privileges to query and add rows to the table Jabulani should also be able to give other users the same pnviledges (7 marks) Examiners: First examiner Dr B Chipangura Second examiner Mr LS Nxumalo External examiner Mr T Museba The end ° UNISA 2018 Annexure A INF3707 OCT/NOV 2018 JustLee Books E-R diagram CUSTOMERS BOOKAUTHOR AUTHOR [Turn over} INF3707 Oct/Nov 2018 Describe Customers ‘isc Type TABLE Opes:_cuSTOMERS VLR LKS: Select * from Customer se es aia how SATE WA is sew emptvazep net tae cu NSA Key wy He exam con te eka ASSMAN STREET. «AUSTIN Ka DSW treet oe JOMES ERNE PO OKT cvereme we oa sane me PEREZ OEE PO DOKEA sumeaK CAA YOM peenemet ce fow eas UME. THHEAGT BWVARWOT ATTA GR 20004 Ms fo MecoveRN REESE FO WOK own kom een et woz MORENE | WL PO BoxETY soston uk tio Ne wtaaugane mt {012 (MOUYEN | MCHCLAS “SEY WHTEGAGLEAVE CLERWONT «FLT. 100 SE mpgs Describe Orders eit Guan eh Beets ° . 7 4 ° : 7 ? : v 8 v we v 2 v s : v ‘ 2 v 19 (Turn over] m INF3707, OCT/NOV 2018 Select * from Orders “Regula Evciam Seroee' 8heS so Hsien : Se Sees 10 105 oant2008| same WA “2 ror 1010 wainoe — OeOYamNe IHAEASTSAVANIA ATLANTA GA mm v2 on canvrogs — ovorRom se TLAGIRCLE ecaco woes 3 toot woinoe —ouOYaIOY SSEMAGHOUALANE —EASIPONT. FL um 4 vor 10 wove 4052009 $61 ROUNDABOUT WAY TRENTON AE wees 0110 cvoinoe owammne IB GANDAVEWE MACON GA 08 os 08 wovl00 OAODRINE SSBACAPITOLMIY —TAULAIASSEE FL ner 2 ‘or 07 owon9e exouzmoS SEDMANSTREET. AUSTIN. TK ran veo 180 owoanee — ounvans Gur SOVTHAVERUE — 20:8¢ © err © 1009 1005 0410372008 047052009 9 LIGHTENING RO SEATTLE, WAL 96810 oo 9 vganoes ONO AML WONG WAY HOME MORRISTOWN NI om 2 Describe orderitems Bouvite “Eapiane) aaetiba” Baise TUE rectory bea Type TABLE Opec OROERITEMS aainppaa gS oleate areas 1s FORDERIENS ORDER! UNGER 0 | ! ems NUMBER ° 2 i san vancrare 10 : : v ; usar numer 3 0 : i eagcacu NUMBER = 5 2 : 1 i Select * from orderitems Resuits Erol Gezcnbe S3ved SaL “History oo STZ 995 Frat 1 eraetoon 4 86 | root 2 zeoraasz0 1 45 * y002 1 90431721132 5595, jm naa 5.05 vs 2 neseonise 2095 fim 3 ses 1995 Sim asirasa 2 a8 star 3985 fe) ees os fm eerie ns [Turn over} w INE3707 OcT/Nov 2018 Describe books “Basak “Eigiaie “Desenbe Saved SOC Bisiory ‘Objet Type TABLE Obect_ BOOKS » 7 v tO ‘ v 2 ° v coetaear) 2 v : 5 2 v “ 2 7 vo. renee aie : 1a Select * from books ReaiaEnpiaw Garenbe Saeed 300 HSI 187s 3095 FITNESS | soseen1100 onave0s 4 | o4ost40790 sys42005 1 42 2 . FAMILY LIFE | one a oxe2008 2 wa em 8 CHILDREN | sores 5042003 9 a4 5585 ‘COMPUTER ‘3497212480 cazez0 4 25 1995 ‘COOKING 3087136468 szera00s 2 4725-75098 ‘COMPUTER spsteade2 ovewz005 3 ne 35 COMPUTER seso7eia24 owa12008 2 7a 48 compurer | 2491748020 PAINLESS CHILD-REARING omn7a00s 5 9954 FAMILY LIFE (0200282519 THE WOK WAY TO COOK oatv2004 4 19 7875, ‘COOKING 8117949991 BIG BEAR AND LITTLE DOVE, 10820055 5 8m ‘CHILDREN Describe bookauthor “Boule Erplan Descnbe Sived S00 History (Turn over] v INF3707, OCT/NOV 2018 Select * from bookauthor “Results Explain Describe Saved SCL” History (gle hace a,c [ores sim | | caezezsio si | oworvo7sa 100, 1059831198 F100 1059831198 $100 | 1918762492 W100 1915762492 W105 2147428890 W105 2491748320 8100 2491748320 F100 2491748320 R100 3437212490 8100 Deseribe author plays Base SaL peste", (Object Type TABLE Object AUTHOR. [Turn over} “ INF3707, OcT/NOV 2018 Select * from author “esas “expan Geschbs Saved 30 sie ise a aac sO SMITH o> Jones co AUSTIN woo Naennez ico KZOCHSKY TAMARA | pio ponte usa | ats i 8100 ; Ps i ws00 : wos 00 F100 wuio Describe publisher Results Expisn Deschbe Saved SOL ‘Objet Type TABLE Object PUBLISHER. ee aaa PUBLISHER PURQ © NUMBER 2 ° 1 NAME —-VARCHARZ 23 zl v CONTACT VARCHAR 15 v PHONE — VARCHARZ «120 7 : v 7 Wesuite “Explain Devenbe Saved SOL History tenants Us Tit \ PUBLISH OUR WAY JANE TOMLIN 010-410-000 | AMERICAN PUBLISHING —_DAVIDDAVIDSON 600-556-1211 i J 3 rows returned i 0 03 seconds [Turn over] vu INF3707 OCT/NOV 2018 Describe promotion Seabitg “Eaplain” eaetibe “85Ved BOL Histony zs v MINREIAL NUMBER 5 2 : v MAXREIAL, NUMBER 5 2 ci vo Select * from promotion “Results Expiair jeseribe Saved SOL Mistor | FREE SHIPPING 5601 999.99 | eoormarner 0 2 | BOOK LABELS — 1201 2 2 FREE SHIPPING 5601 999.99 Grows returned in0 00 seconds Download ‘The end © UNISA 2018

You might also like