INF3707/201/02/2018 Tutorial Letter 201/02/2018 Database Design and Implementation INF3707 Semesters 2: Assignment 01 solutions School of Computing This tutorial letter contains important information about your module. BARCODE
Assignment 1 Total marks Due date 25 marks (100%) Note that this is a COMPULSORY assignment! If you do not complete this assignment and submit it by the due date, you will not gain examination entry! 1. Which of the following software is used to create and maintain the physical database? 1. Data mining 2. Database Management System (DBMS) 3. E-R Model 4. Systems Development Life Cycle (SDLC) 2. Which of the following may contain transitive dependencies, but not partial dependencies? 1. Unnormalized data 2. First normal form (1NF) 3. Second normal form (2NF) 4. Third normal form (3NF) Answer 3 3. Which of the following represents a field in a table? 1. A record 2. A row 3. Column 4. An entity Answer 3 4. To indicate which database table contains the data to be selected by a query, the table name should be listed in which clause. 1. WHERE 2. SELECT 3. HAVING 4. FROM ANSWER: 4 5. If the results of a SELECT statement include more than one column of data, the column names must be separated in the SELECT clause by which of the following symbols? 1. " " 2. ' ' 3. * 4., ANSWER: 4 2
INF3707 6. Which of the following will display the new retail price of each book as 20 percent more than it originally cost? 1. SELECT title, retail*.2 "New Retail Price" FROM books 2. SELECT title, retail+.20 "New Retail Price" FROM books; 3. SELECT title, cost*.20 "New Retail Price" FROM books; 4. SELECT title, cost*1.20 "New Retail Price" FROM books; 7. Which keywords are used to complete the deletion of a column previously marked with SET UNUSED? 1. DELETE UNUSED COLUMNS 2. DROP UNUSED COLUMNS 3. UNSET UNUSED COLUMNS 4. DROP SET COLUMNS ANSWER: 2 8. Which command instructs Oracle 12c to create a new table from existing data? 1. CREATE NEW TABLE 2. CREATE TABLE...FROM 3. CREATE TABLE 4. CREATE TABLE...AS 9. Which of the following keywords cannot be used to modify an existing table? 1. ALTER TABLE...ADD 2. ALTER TABLE...DROP COLUMN 3. ALTER TABLE...MODIFY 4. ALTER TABLE...AS 10. Which of the following rules does not apply to column names in Oracle 12c? 1. Column names can contain numbers. 2. Column names can be up to 30 characters in length. 3. Column names must begin with a letter. 4. Column names can contain an ampersand (&). ANSWER: 4 11. Which of the following commands changes a table s name from OLDNAME to NEWNAME? 1. RENAME oldname TO newname 2. REMANE table FROM oldname TO newname 3. ALTER TABLE oldname MODIFY TO newname 4. CREATE TABLE newname (SELECT * FROM oldname) Answer 1 12. Which of the following statements about creating constraints is incorrect? 1 If you do not provide a name for a constraint, the Oracle 12c server 3
will issue an error message. 2. There are two approaches for creating constraints: at the column level or the table level. 3. One industry convention is to use the format tablename_columnname_constraint type for the constraint name. 4. none of the above ANSWER: 1 13. 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 constraint? 1. ALTER TABLE orderitems DISABLE PRIMARY KEY CONSTRAINT; 2. ALTER TABLE orderitems DISABLE CONSTRAINT orderitems_pk; 3. ALTER TABLE orderitems REMOVE PRIMARY KEY CONSTRAINT; 4. ALTER TABLE orderitems MODIFY PRIMARY KEY CONSTRAINT DISABLE; ANSWER: 2 14. Which of the following datatypes refers to fixed-length character data, where n represents the maximum length of the column? 1. CHAR(n) 2. VARCHAR(n) 3. VARCHAR2(n) 4. LONG ANSWER: 1 15. 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 drop the constraint? 1. ALTER TABLE orderitems DROP PRIMARY KEY CONSTRAINT; 2. ALTER TABLE orderitems DELETE CONSTRAINT orderitems_pk; 3. ALTER TABLE orderitems DROP PRIMARY KEY; 4. ALTER TABLE orderitems MODIFY PRIMARY KEY CONSTRAINT DROP; ANSWER: 3 16. Based on the structure of the ORDERITEMS table, which of the following commands will make certain that the ISBN entered actually exists in the ISBN column of the BOOKS table? 1. ALTER TABLE orderitems ADD FOREIGN KEY isbn REFERENCES BOOKS TABLE (isbn); 4
2. ALTER TABLE orderitems MODIFY FOREIGN KEY (isbn) REFERENCES books(isbn); 3. ALTER TABLE orderitems CREATE FOREIGN KEY (isbn) REFERENCES books(isbn); 4. ALTER TABLE orderitems ADD FOREIGN KEY (isbn) REFERENCES books(isbn); 17. Which of the following commands is used to add data to an existing row in a table? 1. ADD 2. UPDATE 3. INSERT 4. MODIFY 18. Which keywords create a shared lock on a table to prevent another user from making changes to data in specified columns? 1. SELECT...LOCK 2. SELECT...COMMIT 3. SELECT...FOR UPDATE 4. SELECT...FOR CHANGE ANSWER: 3 19. Contents of the PUBLISHER table INF3707 Which of the following commands will delete only publisher 4 from the PUBLISHER table? 1. DELETE FROM publisher; 2. DELETE pubid = 4 FROM publisher; 3. DROP FROM publisher WHERE pubid = 4; 4. DELETE FROM publisher WHERE pubid = 4; 20. Based on the contents of the PUBLISHER table, which of the following will add a new record to the table? 1. INSERT INTO publisher VALUES ('BOOKS MADE CHEAP', '800-111-2222'); 2. INSERT INTO publisher (pubid, name) VALUES (6, 'BOOKS MADE CHEAP'); 3. UPDATE publisher 5
VALUES ('BOOKS MADE CHEAP', '800-111-2222'); 4. UPDATE publisher (pubid, name) VALUES (6, 'BOOKS MADE CHEAP'); 21. Which of the following commands is used to create a function-based index? 1. CREATE FUNCTION INDEX...ON 2. CREATE INDEX...ON 3. CREATE INDEX...FOR 4. CREATE INDEX...FUNCTION 22. Which of the following methods is not used in an INSERT statement to enable the use of a DEFAULT sequence value defined for a column? 1. Use the DEFAULT keyword 2. Do not include the column 3. Use NEXTVAL to call the value 4. All of the above Answer 3 23. Which of the following commands are used to create a user account? 1. CREATE NEW USER username IDENTIFIED BY password; 2. CREATE USERNAME username IDENTITY password; 3. CREATE USER username PASSWORD password; 4. CREATE USER username IDENTIFIED BY password; answer 4 24. Which command will delete a user account from a database? 1. DELETE USER username; 2. DELETE USER username IDENTIFIED BY password; 3. DROP USER username IDENTIFIED BY password; 4. DROP USER username; 25. Which of the following SQL statements will create a new role named PRCLERK? 1. CREATE prclerk; 2. CREATE ROLE prclerk; 3. CREATE ROLE prclerk ON payroll; 4. CREATE ROLE prclerk WITH SELECT ANY TABLE PRIVILEGE; 6