You are on page 1of 19

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Semester 1 Final Exam covers Sections 11-17 of Database Design. Section 12 (Answer all questions in this section) 1. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid st atement. True or False? Mark for Review (1) Points True False (*) Correct. 2. Once you have created a table, it is not possible to alter the definition of it. If you need to add a new column you must delete the table definition and create a new, correct table. True or False? Mark for Review (1) Points True False (*) Correct. 3. What command can be used to create a new row in a table in the database? Mark for Review (1) Points CREATE NEW ADD INSERT (*) Correct. 4. What command will return data from the database to you? Mark for Review (1) Points FETCH GET

SELECT (*) RETURN Correct. 5. The _______ clause can be added to a SELECT statement to return a subset o f the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct.

Section 16 (Answer all questions in this section) 6. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees; How will the heading for the SALARY column appear in the display by default in O racle Application Express? Mark for Review (1) Points The heading will display with the first character capitalized and centered. The heading will display with the first character capitalized and left justi fied. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 7. You need to display all the employees whose last name starts with the lett ers Sm . Which WHERE clause should you use? Mark for Review (1) Points WHERE last_name LIKE 'Sm%' (*) WHERE last_name LIKE '%Sm'

WHERE last_name LIKE '_Sm' WHERE last_name LIKE 'Sm_' Correct. 8. The PLAYERS table contains these columns: PLAYER_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2 (20) TEAM_ID NUMBER (4) MANAGER_ID NUMBER (9) POSITION_ID NUMBER (4) Which SELECT statement should you use if you want to display unique combinations of the TEAM_ID and MANAGER_ID columns? Mark for Review (1) Points SELECT * FROM players; SELECT team_id, manager_id FROM players; SELECT DISTINCT team_id, manager_id FROM players; (*) SELECT team_id, DISTINCT manager_id FROM players; SELECT team_id, manager_id DISTINCT FROM players; Correct. 9. You want to retrieve a list of customers whose last names begin with the l etters Fr . Which symbol should you include in the WHERE clause of your SELECT s tatement to achieve the desired result? Mark for Review (1) Points % (*) ~ # * Correct. 10. Which SELECT statement will display both unique and non-unique combinatio ns of the MANAGER_ID and DEPARTMENT_ID values from the EMPLOYEES table? Mark fo r Review (1) Points SELECT manager_id, department_id DISTINCT FROM employees; SELECT manager_id, department_id FROM employees; (*)

SELECT DISTINCT manager_id, department_id FROM employees; SELECT manager_id, DISTINCT department_id FROM employees; Correct.

Page 1 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Semester 1 Final Exam covers Sections 11-17 of Database Design. Section 16 (Answer all questions in this section) 11. The EMPLOYEES table includes these columns: EMPLOYEE_ID NUMBER(4) NOT NULL LAST_NAME VARCHAR2(15) NOT NULL FIRST_NAME VARCHAR2(10) NOT NULL HIRE_DATE DATE NOT NULL You want to produce a report that provides the last names, first names and hire dates of those employees who were hired between March 1, 2000, and August 30, 20 00. Which statements can you issue to accomplish this task? Mark for Review (1) Points SELECT last_name, first_name, hire_date FROM employees WHERE hire_date BETWEEN '01-MAR-00' AND '30-AUG-00'; (*) SELECT last_name, first_name, hire_date FROM employees WHERE hire_date BETWEEN '30-AUG-00' AND '01-MAR-00'; SELECT last_name, first_name, hire_date FROM employees GROUP BY hire_date >= '01-MAR-00' and hire_date <= '30- AUG-00'; SELECT last_name, first_name, hire_date FROM employees

AND hire_date >= '01-MAR-00' and hire_date <= '30-AUG- 00';

Correct. 12. Which comparison condition would you use to select rows that match a char acter pattern? Mark for Review (1) Points IN LIKE (*) ALMOST SIMILAR Correct. 13. Which operator is used to combine columns of character strings to other c olumns? Mark for Review (1) Points * / + || (*) Correct. 14. When using the LIKE condition, which symbol represents any sequence of no ne, one or more characters? Mark for Review (1) Points _ % (*) # & Correct. 15. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT

FROM (*) WHERE NONE Incorrect. See Section 16 Lesson 1. 16. You need to display only unique combinations of the LAST_NAME and MANAGER _ID columns in the EMPLOYEES table. Which keyword should you include in the SELE CT clause? Mark for Review (1) Points ONLY UNIQUEONE DISTINCT (*) DISTINCTROW Correct. 17. You need to display employees whose salary is in the range of 10000 throu gh 25000 for employees in department 50 . What does the WHERE clause look like? Mark for Review (1) Points WHERE department_id < 50 AND salary BETWEEN 10000 AND 25000 WHERE department_id > 50 AND salary BETWEEN 10000 AND 25000 WHERE department_id = 50 AND salary BETWEEN 25001 AND 10001 WHERE department_id = 50 AND salary BETWEEN 25000 AND 10000 (*) Correct. 18. When using the LIKE condition to search for _ symbols, which character ca n you use as the default ESCAPE option? Mark for Review (1) Points % ^

& \ (*) Correct.

Section 17 (Answer all questions in this section) 19. Which SELECT statement should you use to limit the display of product inf ormation to those products with a price of less than 50? Mark for Review (1) Points SELECT product_id, product_name FROM products WHERE price < 50; (*) SELECT product_id, product_name FROM products HAVING price < 50; SELECT product_id, product_name FROM products WHERE price <= 50; SELECT product_id, product_name FROM products GROUP BY price < 50; SELECT product_id, product_name FROM products WHERE price < 50.00 GROUP BY price;

Correct. 20. Evaluate this SELECT statement: SELECT * FROM employees WHERE salary > 30000 AND department_id = 10 OR email IS NOT NULL; Which statement is true? Mark for Review (1) Points

The OR condition will be evaluated before the AND condition. The AND condition will be evaluated before the OR condition. (*) The OR and AND conditions have the same precedence and will be evaluated fro m left to right The OR and AND conditions have the same precedence and will be evaluated fro m right to left Correct.

Page 2 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Semester 1 Final Exam covers Sections 11-17 of Database Design. Section 17 (Answer all questions in this section) 21. You query the database with this SQL statement: SELECT price FROM products WHERE price IN(1, 25, 50, 250) AND (price BETWEEN 25 AND 40 OR price > 50); Which two values could the statement return? (Choose two.) Mark for Review (1) Points (Choose all correct answers) 1 50 25 (*) 10 250 (*) Correct.

22. You attempt to query the database with this SQL statement: SELECT product_id "Product Number", category_id "Category", price "Price" FROM products WHERE "Category" = 5570 ORDER BY "Product Number"; This statement fails when executed. Which clause contains a syntax error? Mark for Review (1) Points SELECT product_id "Product Number", category_id "Category", price "price" ORDER BY "Product Number"; FROM products WHERE "Category" = 5570 (*) Correct. 23. You need to create a report to display all employees that were hired on o r after January 1, 1996. The data should display in this format: Employee Start Date and Salary 14837 - Smith 10-MAY-92 / 5000 Which SELECT statement could you use? Mark for Review (1) Points SELECT employee_id || - || last_name "Employee", hire_date || / || salary "Start Date and Salary FROM employees WHERE hire_date <= '01-JAN-96'; SELECT employee_id ||' '|| last_name "Employee", hire_date ||' '|| salary "Start Date and Salary" FROM employees WHERE hire_date <= 01-JAN-96'; SELECT employee_id ||'"- "|| last_name "Employee", hire_date ||" / "|| salary Start Date and Salary" FROM employees WHERE hire_date <= '01-JAN-96'; SELECT employee_id ||' - '|| last_name 'Employee', hire_date ||' / '|| salary 'Start Date and Salary" FROM employees WHERE hire_date <= '01-JAN-96'; SELECT employee_id ||' - '|| last_name "Employee", hire_date ||' / '|| salary "Start Date and Salary" FROM employees

WHERE hire_date <= '01-JAN-96'; (*)

Correct. 24. Evaluate this SELECT statement: SELECT * FROM employees WHERE department_id = 34 OR department_id = 45 OR department_id = 67; Which operator is the equivalent of the OR conditions used in this SELECT statem ent? Mark for Review (1) Points IN (*) AND LIKE BETWEEN ... AND ... Correct. 25. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) PK LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) DEPARTMENT_ID NUMBER(9) Compare these two SQL statements: 1. SELECT DISTINCT department_id DEPT, last_name, first_name FROM employees ORDER BY department_id; 2. SELECT department_id DEPT, last_name, first_name FROM employees ORDER BY DEPT; How will the results differ? Mark for Review (1) Points One of the statements will return a syntax error. One of the statements will eliminate all duplicate DEPARTMENT_ID values. There is no difference in the result between the two statements. (*) The statements will sort on different column values.

Correct. 26. The PLAYERS table contains these columns: PLAYERS TABLE: LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) SALARY NUMBER(8,2) TEAM_ID NUMBER(4) MANAGER_ID NUMBER(9) POSITION_ID NUMBER(4) You want to display all players' names with position 6900 or greater. You want t he players names to be displayed alphabetically by last name and then by first n ame. Which statement should you use to achieve the required results? Mark for Review (1) Points SELECT last_name, first_name FROM players WHERE position_id >= 6900 ORDER BY last_name, first_name; (*) SELECT last_name, first_name FROM players WHERE position_id > 6900 ORDER BY last_name, first_name; SELECT last_name, first_name FROM players WHERE position_id <= 6900 ORDER BY last_name, first_name; SELECT last_name, first_name FROM players WHERE position_id >= 6900 ORDER BY last_name DESC, first_name;

Correct. 27. The PLAYERS table contains these columns: PLAYERS TABLE: LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) SALARY NUMBER(8,2) TEAM_ID NUMBER(4) MANAGER_ID NUMBER(9) POSITION_ID NUMBER(4) You must display the player name, team id, and salary for players whose salary i s in the range from 25000 through 100000 and whose team id is in the range of 12

00 through 1500. The results must be sorted by team id from lowest to highest an d then further sorted by salary from highest to lowest. Which statement should y ou use to display the desired result? Mark for Review (1) Points SELECT last_name, first_name, team_id, salary FROM players WHERE (salary > 25000 OR salary < 100000) AND team_id BETWEEN 1200 AND 1500 ORDER BY team_id, salary; SELECT last_name, first_name, team_id, salary FROM players WHERE salary BETWEEN 25000 AND 100000 AND team_id BETWEEN 1200 AND 1500 ORDER BY team_id, salary DESC; (*) SELECT last_name, first_name, team_id, salary FROM players WHERE salary > 24999.99 AND salary < 100000 AND team_id BETWEEN 1200 AND 1500 ORDER BY team_id ASC, salary DESC; SELECT last_name, first_name, team_id, salary FROM players WHERE salary BETWEEN 24999.99 AND 100000.01 AND team_id BETWEEN 1200 AND 1500 ORDER BY team_id DESC, salary DESC;

Correct. 28. Which of the following are TRUE regarding the logical AND operator? Mark for Review (1) Points TRUE AND TRUE return FALSE TRUE AND FALSE return TRUE FALSE AND TRUE return NULL TRUE AND FALSE return FALSE (*) Correct. 29. You need to change the default sort order of the ORDER BY clause so that the data is displayed in reverse alphabetical order. Which keyword should you in clude in the ORDER BY clause? Mark for Review (1) Points

DESC (*) ASC SORT CHANGE Correct. 30. Which clause would you include in a SELECT statement to sort the rows ret urned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct.

Page 3 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Semester 1 Final Exam covers Sections 11-17 of Database Design. Section 17 (Answer all questions in this section) 31. Which statement about the logical operators is true? Mark for Review (1) Points The order of operator precedence is AND, OR, and NOT. The order of operator precedence is AND, NOT, and OR. The order of operator precedence is NOT, OR, and AND. The order of operator precedence is NOT, AND, and OR. (*)

Correct. 32. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points True (*) False Correct. 33. Which logical operator returns TRUE if either condition is true? Mark fo r Review (1) Points OR (*) AND NOT BOTH Correct.

Section 11 (Answer all questions in this section) 34. In a physical data model, a relationship is represented as a combination of: (Choose Two) Mark for Review (1) Points (Choose all correct answers) Column Primary Key or Unique Key (*) Check Constraint or Unique Key Foreign Key (*) Incorrect. Refer to Section 11 Lesson 2. 35. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table

Foreign Key Constraint Column (*) Correct 36. In an Oracle database, why would 1_TABLE not work as a table name? Mark for Review (1) Points The database does not understand all capital letters There is no problem here. You can create a table called 1_TABLE. Object names must not start with a number. They must begin with a letter (*) TABLE is a reserved word Correct 37. An "Arc Implementation" can be done just like any other Relationship - yo u simply add the required Foreign Keys. True or False? Mark for Review (1) Points True False (*) Correct 38. One-to-One relationships are transformed into Check Constraints in the ta bles created at either end of that relationship. True or False? Mark for Review (1) Points True False (*) Correct 39. A foreign key cannot refer to a primary key in the same table. True or Fa lse? Mark for Review (1) Points True False (*)

Correct 40. The text below is an example of what constraint type: If the number of BOOKS lent to a BORROWER in the LIBRARY exceeds 5, then we must send him/her a letter requesting the return of the BOOKS, which will require ex tra programming to enforce. Mark for Review (1) Points Entity integrity User-defined integrity (*) Column integrity Referential integrity Correct

Page 4 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica tes a correct answer. Semester 1 Final Exam covers Sections 11-17 of Database Design. Section 11 (Answer all questions in this section) 41. The explanation below is a User Defined integrity rule and must therefore be manually coded, the Database cannot enforce this rule automatically: A primary key must be unique, and no part of the primary key can be null. True o r False? Mark for Review (1) Points True False (*) Correct 42. A table must have a primary key. True or False? Mark for Review

(1) Points True False (*) Incorrect. Refer to Section 11 Lesson 1. 43. Identify all of the incorrect statements that complete this sentence: A p rimary key is: (Choose three) Mark for Review (1) Points (Choose all correct answers) A single column that uniquely identifies each column in a table (*) One or more columns in a table that uniquely identifies each row in that tab le A set of columns in one table that uniquely identifies each row in another t able (*) Only one column that must be null (*) Correct

Section 15 (Answer all questions in this section) 44. Which SQL keyword specifies that an alias will be substituted for a colum n name in the output of a SQL query? Mark for Review (1) Points AS (*) OR AND SUBSTITUTE Correct. 45. Which statement best describes how arithmetic expressions are handled? M ark for Review (1) Points Addition operations are handled before any other operations. Multiplication and subtraction operations are handled before any other opera tions.

Multiplication and addition operations are handled before subtraction and di vision operations. Division and multiplication operations are handled before subtraction and ad dition operations. (*) Correct. 46. The EMPLOYEES table contains these columns: SALARY NUMBER(7,2) BONUS NUMBER(7,2) COMMISSION_PCT NUMBER(2,2) All three columns contain values greater than zero. There is one row of data in the table and the values are as follows: Salary = 500, Bonus = 50, Commission_pct = .5 Evaluate these two SQL statements: 1. SELECT salary + bonus + commission_pct * salary - bonus AS income FROM employees; 2. SELECT (salary + bonus ) + commission_pct * (salary - bonus) income FROM employees; What will be the result? Mark for Review (1) Points Statement 1 will return a higher value than statement 2. Statement 2 will return a higher value than statement 1. (*) Statement 1 will display a different column heading. One of the statements will NOT execute. Correct. 47. When you use the SELECT clause to list one or two columns only from a tab le and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection Correct.

48. In a SQL statement, which clause specifies one or more columns to be retu rned by the query? Mark for Review (1) Points SELECT (*) FROM WHERE Any of the above options, you can list columns wherever you want to in a SEL ECT statement. Correct. 49. In which clause of a SELECT statement would you specify the name of the t able or tables being queried? Mark for Review (1) Points The FROM clause (*) The SELECT clause The WHERE clause Any of the above options, you can list tables wherever you want to in a SELE CT statement. Correct. 50. If a SQL statement returns data from two or more tables, which SQL capabi lity is being used? Mark for Review (1) Points Selection Projection Joining (*) Insertion Correct.

Page 5 of 5

You might also like