Inf3707 2019 6 e 1

You might also like

Download as pdf
Download as pdf
You are on page 1of 13
UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS UNISA ec INF3707 May/June 2018 Database Design and Implementation Duraton 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 6 pages plus an Annexure with 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 a 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. Nooauns [Tum over] 2 INF3707 MAY/JUNE 2019 Section A: Multiple choice questions [40 marks} © Choose the correct answer Each correct answer carries 2 marks. ‘© Wnte down the question number and the letter of the correct answer or an answers, for example 11 Bor 12B,D,E Some questions have more than one correct answers 11 Which of the following 1s true about the SQL query given below? (Choose the best answer) Select coll, col2 From tabl Where coll = ‘A’ Order by col2 DESC, coll; A. Itwill display the row which has the coll value as order and then col2 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 coll tn the ORDER BY clause will be discarded. D_ It wall display the row which has the coll value as'A' ordered by the coll and then followed by col2 as the execution of the ORDER BY clause happens from the order of columns 1n the SELECT statement ordered by the coll in the descending 1 2 What does the following query do? (Choose the best answer) Select isbn, title from BOOKS where (pubid, category) IN (select pubad,category from BOOKS where title like 'SORACLE$') ‘A. It determines which publisher published a book belonging to the Oracle category and then lists all other books published by that same publisher B. It lists all publishers and categones containing the value of ORACLE It ists the ISBN and ttle of all books belonging to the same category and having the same publisher as any book with the phrase ORACLE in tts title D None of the above The query contains a multiple-row operator and because the inner query retums only one value, the SELECT statement will fail and return an error message [Tum over} 1NF3707 MAY/JUNE 2019 13 Based on the structure of the CUSTOMERS table given below, which of the following is a valid SQL statement? (Choose the best answer) nun? Type ‘cusronent NOT MULL MuHBERCA) LasTAanE, aRcHaRa( FURSTNANE WARCHARD (| ADDRESS aRCHARZ( cry aRCHARZ(42) stare vaRcuana(2) aie vRREHARZ(S) REFERRED HUMBER Ci) A. CREATE PUBLIC INDEX customers_name_id, ON customers (lastname, firstname), B_ CREATE BITMAP INDEX customers_name idx. FOR customers (lastname), © CREATE: INDEX customers_name_idx ON customers (lastname, firstname), D_ CREATE B_TREE INDEX customers_name_idx FOR customers (lastname), 14 Which data dictionary objects contain a column named HIDDEN COLUMN? (Choose the best answer) USER_HIDF_COLS USER_TABLES USER_COLUMNS USER_TAB_COLS gaw> 15 Which of the following commands lock the Justl.ec database’ BOOKS table in EXCLUSIVE mode? (Choose the best answer) ‘A LOCK table BOOKS EXCLUSIVELY B_ LOCK table BOOKS IN EXCLUSIVE MODE C LOCK table BOOKS TO OTHER USERS D_ All the answers are correct 16 You successfully execute the following SQL statement GRANT UPDATE (Orderdate} ON Orders TO davad WITH GRANT OPTION; Which two statements are true? (Choose 2 best answers that apply) DAVID may grant thts privilege to all users in the database, but he may not grant it to PUBLIC DAVID may grant this privilege to a role that has been granted to him DAVID may revoke this privilege from users who have been granted this privilege by him. The DBA may revoke this privilege from roles that have been granted this privilege by DAVID caw> [Turn over] 4 INF3707 MAYAUNE 2019 1.7 Which three statements are true about roles? (Choose 3 best answers that apply) ‘A. A password may be specified for a role only when the role is created. B_Arole may be granted both system and object privileges. . Arole may be dropped only after itis revoked manually from all users and roles to which it has been granted D. Multiple roles may be granted to a role, E. Multiple roles granted to a user may be enabled as default roles for that user. 1.8 Which three statements are true about indexes in Oracle Database 12c? (Choose 3 best answers that apply) ‘A. There may be more than one index on a single column B, Indexes may not always speed up data access to table data C. Invisible indexes are not maintained by data manipulation language (DML) operations D. Multiple invisible indexes may exist on a column. E_ Indexes may be created on a view 1.9 Which of the following are valid CREATE TABLE statements? (Choose 3 best answers that apply.) A CREATE TABLE $ORDERS (TD NUMBER,NAME, VARCHAR2 (30) ) + B. CREATE TABLE CUSTOMER HISTORY (1D NUMBER, NAME VARCHAR? (30)) + c CREATE TABLE “Boat Inventory” {1D NUMBER, NAME VARCHAR2(30)) 7 D. CREATE TABLE workSchedule (ID NUMBER, NAME VARCHAR? (30)) 7 110 Which of the following are Data Manipulation Language statements? (Choose 2 best answers that apply ) A. SELECT B. GRANT C. INSERT D DROP 111 Which of the following is true of the ORDER BY clause? (Choose 2 best answers that apply.) A. It can be used in the UPDATE statement as well as SELECT and DELETE B It can sort rows based on data that isn’t displayed as part of the SELECT statement C. Ifthe list of ORDER BY expressions uses the “by position” form, then all expressions in the ORDER BY must use the “by position” form. D. Its optional. (Tum over} 5 INF3707 MAY/JUNE 2019 Question 2 [24 marks] 2.1 Discuss the following types of joins (8 marks) 1 Eq ii, Selfjoms nti Inner joins ww Outer jomns 2.2 Based on the tables of the JustLee books database, determine the average profit generated by the orders in the ORDERS table, Calculate the total profit ofthe orders before finding the average profit. Create the query using group functions AVG, SUM and GROUP BY Base your query on the BOOKS, ORDERS and ORDERITEMS tables. (10 marks) 2.3 Study the two pieces of code presented below, Code 1 and Code 2 Code 1 creates a database Table named TEST_IDENT and code 2 inserts data into the TSET_IDENT table What 1s the output after execution Code | and Code 2” Explain your answer. (6 marks) Code 1 Create table TEST_IDENT (coll number generated as identity primary key,col2 number); Code 2 Insert into TEST_IDENT (coll) values (350) Insert 1nto TEST_IDENT (coll, col2) values (222, 355) Insert into TEST_IDENT (coli, col2) values (Default, 360} Question 3 136 marks] JustLee Books would like to create some new tables to store office equipment inventory data. The diagram below shows a basic E-R model for the three tables including the needed columns and relationship lines The underlined columns uniquely identify each row in the associated tables DEPRTMENT EQUIPMENT EQUIPTYPE Dept ID _______g} Emin 4+! Equntype Dept_Name Equip_dese EquipType_Name Fax Purchase. date Rating Dept_ID EquipType_ID ‘After analysing the data requirements, the following list of requirements, which will be addressed with constraints, were developed Each department must be unique (Dept_ID, Number (2), CONSTRAINT PRIMARY KEY) Each department must be assigned a name (Dept_Name, varchar 2 (10)) Each equipment type must be unique (EquipType_ID, Number (2), CONSTRAINT PRIMARY KEY) [Tum over} 6 INF3707 MAYAJUNE 2019 Each equipment type must be assigned a name (Equip Name, varchar? (10) «Each equipment item must be unique (Equip_ID Number (5), CONSTRAINT PRIMARY KEY) «Each equipment item must be assigned a valid department (CONSTRAINT equip_dept_1d_fk FOREIGN KEY) * An equipment item must be assigned an equipment type, and it must be valid (CONSTRAINT ‘equip _type_id_fk FOREIGN KEY) ‘© Valid rating values for equipment are A, B, and C (CONSTRAINT iquip_rating_ck) 3.1 Based on the information provided, write SQL statements for creating the EQUIPMENT TABLE, the table in the middle of the E-R model. (10 marks). 3 2 Display all the constraints that exists in the EQUIPMENT table (5 marks). 3.3 Create a sequence for populating the Equip TD column of the EQUIPMENT table. Name the sequence Equip Data_TD_Seq. Start the sequence at 10, increment the sequence by 2, have a maximum value of 1000 and do not allow caching. (S marks) 3.4 Add the data in the table below to the EQUIPMENT table Use the Equip_Data_ID_Seq sequence to populate the Equip ad column G marks) Equip_ad | Equip_desc | Parchase_date |Rating | Dept_1D_| Equspype_ID Fork aft | 21-0etober~ |X é 70 2018 3.5 Disable the aquip_rating_ck constraint. (2 marks) 3.6 Drop the primary key for the EQUIPMENT table (2matks) 3.7 Create a private synonym that enables you to reference Equap_Data_ID_Seq object as EQUIP_DATA (2 marks) 3.8 Create a B-tree index on the EQUIPMENT’s Equip_desc column. Verify that the index exists, by querying the data dictionary Remove the index from data dictionary. (S marks) Examiners Firstexaminer- Dr. B. Chipangura Second examiner: Mr. L. Nxumalo External examiner’ Mr. T Museba The end © UNISA 2019 Annexure A JustLee Books F-R diagram {Turn over! Describe Customers ‘ea Type TABLE Onset CUSTOMERE NMR ° . Sere VARCHAR 1000 2 vancwana 10 : See Heeeeee vancuana 200 7 : v vancuana 12 7 7 v vancmna 2 7 : Rateaaue VARCHAR 8 et etee wen. 4 ° Maes owe 2 7 : Mae cee VarcHAR2 30 7 : Mea cee 110 Select * from Customer ‘or MORALES BONTA estrone = besa voor THOMSON FAH PO BOXERS SAMIAWONCA CA 0104 “ so sum tA goes TUAMSEE Rt = abt ——-PERSON THOMAS GITSCUTHANEINE BOE am fw reset ue araro choY PO noe seAME WA ee tw eterno ne om RUZ MESA enDIRTROKD new oy tae Ne excep con oor Gam Taney SISIMANSTRET AUSTIN «TK THD 1 SY sempre 08 ones ae pO Gor oeveme wr eam Meramec tom PEREZ wRGE PO NOX sunmee cA St tom pene os MeGovERN REESE PO BOK cwaco kc Neemmenatret MEADE wu PO BoxaTY costo wk a0 Ne vacate rt NOWEK —MOHOUUS —NTHHITEEAGLE AWE CLERMONT «FL NN F008 SE tne cusTate PROERDATE OATE 7 : ’ v 8 v 6 ¥ SHPSIAIE VARCHARZ 2 ¥ suene VARCHAR & : ae Gepost NUMBER = 2 v [Turn over} wa ? a 2 sono mavens o4otamme TUACRCLE cwcaco ok fone > 10st eovan —ovotame RAMAGHOUALINE EASTPORT. FL ma 4 soe 14012008 04082009. SEFROUNDABOUT WAY TRENTON KE vos 1s 08 vorames — o4G272008 COBGAAND AVENE — MACON A an 2 om 1003 wares 04022008 KEBACAPTOLIHYY —TALANASSEE FL amor 2 ‘or sor yan 04047009. SISDMANSTREET = AUSTIN TK mo om scot uaz 0402009 CEERI SOMTKAVENLE BOISE ° wor 3 som 1005 waazos 0408008 LIGMTENNORD = SEATIE NA ano on 0 (woazm09 04002008 SEONG WAT HOME MORRISTOWN NI ome 2 Describe orderitems Deserbe Obes Tyoe TABLE Object ORDERITEMS ORDERITENS OADESE NUMBER 4 ° 7 NUMBER 2 ° 2 VARCHAR SLANT. NUMBER, 3 ° PAIDEAGLL NUMBER 5 2 1s Select * from orderitems Resuhs 3 Ce a soot 22D 1995, sort Sau7aBr001 4 3188 sor 2 aarT4aa20 1 545 soot uagtraiss 2 5568 Ll 5505 so 2 go8a1108 1 3005 so 8 asa 1995 woe 1 2aa7aas20 2 25.45 tos = 1 2yaavea90 + 3095 ns} asaenazr + ses sor} 3087130488 3 7218, [Turn over} Describe books Deserbe (Object Type TABLE Ctyect BOOKS: 2K hay ‘VARCHAR2 10 rue VARCHAR 30 puso", OE peso NUMBER 2 0 esr NUMBER 5 2 Ret NUMBER 5 2 Lact MBER = 2 EATEGH RY VARCHAR 12 v v v v v v v ‘Select * from books enue TOSGOSTI96 GODYEULDINTDMRUTESADAY — 0112005 4 RTS. OHS FITNESS. (w0r140739 REVENGE OF MICKEY wwe 1 2 FAMILY UE 4GaXHITI0 BULOINGACAR WITH TOOTHPICKS oMtez0 2 «7A MSS comoneN 3172119 OATABASE MPLEMENTATION —-OBOATOD. 9 NAO ‘COMPUTER, {3Ma7212100 COOKING ITH MUSHROOMS «0228204 41251006, cooKNG 67190468 HOLY GRAIL OF ORACLE irra 3472S 758838 conpurer: ‘9V6752462 HANOCRANMED COMPUTERS 0va2v2005 321825 ‘COMPUTER, uee7eG02' C-OUSNESS THE EASY WAY osorzo «2078S COMPUTER 2WGY74E20 PAINLESS CHILO-REARING orwro 5 mS AS Fawley UE caveze2s19 THE WOKWAY TO.COOK orm 475 CcooKING SYITEISGE! BIG REAR AND LITTLE DOVE ‘wowoms § sss ‘HLDREN Describe bookauthor Dvscroe ‘Object Type TABLE Object BOOKAUTHOR PIOAUTHOR SAN VARCHARZ 10 suslaony VARCHARZ 4&0 {Turn over] Select * from bookauthor Results ‘SON ‘0132140871 280282519 0401140733, 1050831198 1050831108 1918762402 1918782402 2147428890 2491748320 2491748320 2491748320 3437212600 praery 8100 s100 100 P10 $100 wi00 wi05 wos 8100 F100 R100 8100 Describe author Describe ‘Object Type TABLE Object AUTHOR, ory Sa AUTHOR ALTIQRID VARCHAR 4 Nat cate, VARCHAR? vaRCHAR? SN [Tum over] Select * from author ‘SMT Jones: aust NaRriNeZ KZOCHSKY PORTER ORNS BAKER PETERSON wntre ROBINSON rietos HLKINSON sa sane IANes SHELA raaRa, usa Juans Jack sna usa ROBERT Describe publisher ‘Object Type TABLE Object PUBLISHER tan Oesdabe “faves SOL ua Pe contact pUSUSHER NUMBER 2 o 1 VARCHAR? 20 v VARCHAR? 15 = v VARCHAR? 12, v Select * from publisher Results Eéplae Oescribe iived $90, Heston TTOMMIE SEYMOUR 1 PRINTING ISUS coo. Tian2t 2 PUBLISH OUR Way Jane TOMLIN 610.410.0010 * 3 AMERICAN PUBLISHING DAVID OAVIDSON 800.855.1211 « 4 READING MATERIALS INC RENEESMITH 000.855.6743 * is ReEDWAITE SEBASTIAN JONES 900-555-6204 ‘5 ows retumedin 03 seconds Oowaload [Turn over) Describe promotion Reis tipials Bedeie 51058 Ferononion ier VARCHAR? 15, v ManEETAL NUMBER 5 2 v AXEETAL NUMBER 5 2 v a BOOK COVER 2501 58 FREE SHIPPING 5601 wee | BOOKMARKER 0 2 t BOOK LABELS 1201 25 BOOK COVER 2501 88 EE SHIPPING 5601 999.96 ws retuned In. O0 seconds Download The end ‘OUNISA 2019

You might also like