Final Exam Oracle

232
Test: Final Exam - Database Design Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Section 12 Lesson 1 (Answer all questions in this section) 1. A foreign key can not refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 2. The text below is an example of what constraint type: The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 3. Entity integrity refers to Mark for Review

description

oracle

Transcript of Final Exam Oracle

Page 1: Final Exam Oracle

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 12 Lesson 1 (Answer all questions in this section) 1. A foreign key can not refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 2. The text below is an example of what constraint type: The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 3. Entity integrity refers to Mark for Review

Page 2: Final Exam Oracle

(1) Points Entities always containing text data Entities always containing numeric data Columns having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. Entities having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. (*) Incorrect. Refer to Section 12 4. If a primary key is a set of columns then one column must be null. True or False?Mark for Review (1) Points True False (*) Correct Section 12 Lesson 2 (Answer all questions in this section) 5. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key

Page 3: Final Exam Oracle

Constraint Column (*) Correct 6. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique Identifiers becomes Mark for Review (1) Points Columns Tables Unique Constraints (*) Primary Key Constraints Correct 7. In an Oracle database, why would 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 TABLE. TABLE is a reserved word (*) None of the above Correct

Page 4: Final Exam Oracle

Section 12 Lesson 3 (Answer all questions in this section) 8. The Oracle Database can implement a many to many relationship. You simple create two foreign keys between the two tables. True or False? Mark for Review (1) Points True False (*) Correct 9. What do you create when you transform a one to one relationship from your ER diagram into a physical design? Mark for Review (1) Points Unique key constraints Intersection entity Intersection table (*) Two tables with a Foreign key constraints between them Incorrect. Refer to Section 12 Section 12 Lesson 4 (Answer all questions in this section) 10. When mapping supertypes, relationships at the supertype level transform as

Page 5: Final Exam Oracle

usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns all become mandatory. True or False? Mark for Review (1) Points True False (*) Correct

Page 1 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 12 Lesson 4 (Answer all questions in this section) 11. Which of the following are reasons why you should consider using a Subtype Implementation? Mark for Review (1) Points The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*)

Page 6: Final Exam Oracle

Most of the relationships are at the supertype level Correct Section 13 Lesson 1 (Answer all questions in this section) 12. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. 13. What command can used to create a new row in a table in the database? Mark for Review (1) Points CREATE NEW ADD INSERT (*) Correct.

Page 7: Final Exam Oracle

Section 16 Lesson 1 (Answer all questions in this section) 14. Which statement best describes how arithmetic expressions are handled? Mark for Review (1) Points Addition operations are handled before any other operations. Multiplication and substraction operations are handled before any other operations. Multiplication and addition operations are handled before subtraction and division operations. Division and multiplication operations are handled before subtraction and addition operations. (*) Correct. 15. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct.

Page 8: Final Exam Oracle

16. Evaluate this SELECT statement: SELECT (salary * raise_percent) raise FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return? Mark for Review (1) Points Only zeroes Only null values (*) A null value or a zero depending on the value of the SALARY column A null value or a numeric value depending on the value of the SALARY column Incorrect. See Section 16 17. Which SQL keyword specifies that an alias will be substituted for a column name in the output of a SQL query? Mark for Review (1) Points AS (*) OR AND SUBSTITUTE Correct. 18. You query the database with this SQL statement:

Page 9: Final Exam Oracle

SELECT * FROM students; Why would you use this statement? Mark for Review (1) Points To insert data To view data (*) To display the table structure To delete data Correct. 19. Which keyword can be used to specify a column alias? Mark for Review (1) Points AS (*) DESCRIBE FROM WHERE Correct. 20. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions Multiplications (*)

Page 10: Final Exam Oracle

Additions Divisions Correct.

Page 2 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 16 Lesson 3 (Answer all questions in this section) 21. There is only one kind of software used by all computers. True or Fale? Mark for Review (1) Points True False (*) Correct. 22. In a SELECT statement ADDITIONS are evaluated before Multiplications. True or False? Mark for Review (1) Points

Page 11: Final Exam Oracle

True False (*) Correct Section 17 Lesson 1 (Answer all questions in this section) 23. Which operator is used to combine columns of character strings to other columns? Mark for Review (1) Points * / + || (*) Correct. See Section 17 24. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE

Page 12: Final Exam Oracle

NONE Correct. See Section 17 25. When using the LIKE condition to search for _ symbols, which character can you use as the ESCAPE option? Mark for Review (1) Points % ^ & \ (*) Incorrect. See Section 17 26. What does the DISTINCT keyword do when it is used in a SELECT clause? Mark for Review (1) Points Hides NULL values Eliminates all unique values and compares values Eliminates duplicate rows in the result (*) Eliminates only unique rows in the result Correct. See Section 17 27. Which statement best describes how column headings are displayed by defaultin Oracle Application Express: Mark for Review

Page 13: Final Exam Oracle

(1) Points Column headings are displayed left-justified and in lowercase. Column headings are displayed left-justified and in uppercase. Column headings are displayed centered and in uppercase. (*) Column headings are displayed centered and in mixed case. Correct. See Section 17 28. Which of the following elements cannot be included in a WHERE clause? Mark for Review (1) Points A column alias (*) A column name A comparison condition A constant Correct. See Section 17 Section 17 Lesson 2 (Answer all questions in this section) 29. You need to display all the values in the EMAIL column that contains the underscore (_) character. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? Mark for Review (1) Points

Page 14: Final Exam Oracle

The ESCAPE option (\) and one or more percent signs (%) The (+) operator A percent sign (%) The ESCAPE option (\) (*) Incorrect. See Section 17. 30. The PLAYERS table contains these columns: PLAYER_ID NUMBER (9) Primary Key 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 combinationsof 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.

Page 15: Final Exam Oracle

Page 3 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 17 Lesson 2 (Answer all questions in this section) 31. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND.. Correct. 32. What will the result of the following SELECT statement be:SELECT last_name, salary, salary + 300 FROM employees;

Mark for Review (1) Points

Page 16: Final Exam Oracle

Display the last name, salary and the results of adding 300 to each salary for all the employees (*) Modify the salary column by adding 300 and displaying the last name, salary and the new salary. Modify the salary column by adding 300 and only display the last name and the new salary. Display the last name, salary and the results of adding 300 to the salary of the firstemployee row Correct. 33. Which SELECT statement will display both unique and non-unique combinations of the MANAGER_ID and DEPT_ID values from the EMPLOYEES table? Mark for 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. Section 17 Lesson 3 (Answer all questions in this section) 34. The STUDENT table contains these columns:

Page 17: Final Exam Oracle

STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAJOR_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, major_id FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAJOR_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAJOR_ID can be displayed more than once. Each MAJOR_ID can be displayed only once. Correct. 35. You want to create a report that displays all employees who were hired before January 1, 2000 and whose annual salaries are greater than 50000. The EMPLOYEES table contains these columns:

EMPLOYEE_ID VARCHAR2(5) PRIMARY KEY LAST_NAME VARCHAR2(35) HIREDATE DATE DEPARTMENT_ID NUMBER(4)

The SALARY table contains these columns:

SALARYID VARCHAR2(5) PRIMARY KEY SALARY NUMBER(5, 2)

Page 18: Final Exam Oracle

EMPLOYEE_ID VARCHAR2(5) FOREIGN KEY

Which query should you issue? Mark for Review (1) Points SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary USING employee_id WHERE hiredate < 01-jan-00 AND salary > 50000; SELECT last_name, hiredate, salary FROM employees JOIN salary ON employee_id = employee_id WHERE hiredate < '01-jan-00' AND salary > 50000; SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary WHERE hiredate < '01-jan-00' AND salary > 50000; (*) SELECT last_name, hiredate, salary FROM employees (+) salary WHERE hiredate < '01-jan-00' AND salary > 50000; Correct. 36. 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 first names, last names and hire datesof those employees who were hired between March 1, 2000, and August 30, 2000.

Page 19: Final Exam Oracle

Which statements can you issue to accomplish this task? Mark for Review (1) Points SELECT last_name, first_name 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 WHERE hire_date >= '01-MAR-00' and hire_date <= '30-AUG- 00'; (*) Correct. Section 18 Lesson 1 (Answer all questions in this section) 37. Which logical operator returns TRUE if either condition is true? Mark for Review (1) Points OR (*)

Page 20: Final Exam Oracle

AND NOT BOTH Correct. 38. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 39. Which of the following best describes the meaning of the LIKE operator? Mark for Review (1) Points Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Correct.

Page 21: Final Exam Oracle

40. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Incorrect. See Section 18

Page 4 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 18 Lesson 1 (Answer all questions in this section) 41. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<"

Page 22: Final Exam Oracle

">=" "<=" (*) Correct. 42. 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. Section 18 Lesson 2 (Answer all questions in this section) 43. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only.

Page 23: Final Exam Oracle

The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 44. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR (employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200); Mark for Review (1) Points 19 No rows will be returned. 100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*) 200, 201, 202, 203, 204, 205, 206 Incorrect! See Section 18. 45. You need to create a report to display all employees that were hired on or before 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

Page 24: Final Exam Oracle

SELECT employee_id || - || last_name "Employee", hire_date || / || salary "Start Date and Salary" FROM employeesWHERE 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 employeesWHERE hire_date <= '01-JAN-96'; (*) Correct. 46. Evaluate this SELECT statement: SELECT last_name, first_name, email FROM employees ORDER BY email;

Page 25: Final Exam Oracle

If the EMAIL column contains null values, which statement is true? Mark for Review (1) Points Null email values will be displayed first in the result. Null email values will be displayed last in the result. (*) Null email values will not be displayed in the result. The result will not be sorted. Correct. 47. Which SELECT statement should you use to limit the display of product information 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. 48. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

Page 26: Final Exam Oracle

You need to sort data by manager id values and then alphabetically by employee lastname and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. Section 18 Lesson 3 (Answer all questions in this section) 49. 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 the players names to be displayed alphabetically by last name and then by first name. 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

Page 27: Final Exam Oracle

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. 50. 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

Page 28: Final Exam Oracle

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.

Page 5 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 12 Lesson 1 (Answer all questions in this section) 1. Foreign keys cannot be null. True or False? Mark for Review (1) Points True

Page 29: Final Exam Oracle

False (*) Correct 2. The text below is an example of what constraint type: The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 3. A foreign key can not refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 4. If a primary key is a set of columns then one column must be null. True or False?Mark for Review (1) Points

Page 30: Final Exam Oracle

True False (*) Correct Section 12 Lesson 2 (Answer all questions in this section) 5. Why would this table name NOT work in an Oracle database? This_year_end+next_year Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct 6. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key Constraint Column (*)

Page 31: Final Exam Oracle

Correct 7. In a physical data model, a relationship is represented as a combination of: 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 12 Section 12 Lesson 3 (Answer all questions in this section) 8. Many to many relationships are implemented via a structure called a: ________________ Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype

Page 32: Final Exam Oracle

Correct 9. One-to-One relationships are transformed into Check Constraints in the tables created at either end of that relationship. True or False? Mark for Review (1) Points True False (*) Correct Section 12 Lesson 4 (Answer all questions in this section) 10. When translating an arc relationship to a physical design, you must turn the arcrelationships into foreign keys. Assuming you are implementing an Exclusive Design,you must also create two Unique Key Constraints to ensure the Arc is implemented correctly. True or False? Mark for Review (1) Points True False (*) Correct

Page 1 of 5

Page 33: Final Exam Oracle

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 12 Lesson 4 (Answer all questions in this section) 11. Which of the following are reasons why you should consider using a Subtype Implementation? Mark for Review (1) Points The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*) Most of the relationships are at the supertype level Correct Section 13 Lesson 1 (Answer all questions in this section) 12. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True

Page 34: Final Exam Oracle

False (*) Correct 13. The _______ clause can be added to a select statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct. Section 16 Lesson 1 (Answer all questions in this section) 14. When listing columns in the SELECT list, what should you use to separate the columns? Mark for Review (1) Points Commas (*) Semicolons Dashes Underscores

Page 35: Final Exam Oracle

Correct. 15. Which SQL keyword specifies that an alias will be substituted for a column name in the output of a SQL query? Mark for Review (1) Points AS (*) OR AND SUBSTITUTE Correct. 16. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions Multiplications (*) Additions Divisions Correct. 17. Which statement best describes how arithmetic expressions are handled? Mark for Review (1) Points Addition operations are handled before any other operations.

Page 36: Final Exam Oracle

Multiplication and substraction operations are handled before any other operations. Multiplication and addition operations are handled before subtraction and division operations. Division and multiplication operations are handled before subtraction and addition operations. (*) Correct. 18. Which SQL statement will return an error? Mark for Review (1) Points SEL * FR sky; (*) select star from sky; SELECT star FROM sky; SELECT * FROM sky; Correct. 19. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection

Page 37: Final Exam Oracle

Correct. 20. Which keyword can be used to specify a column alias? Mark for Review (1) Points AS (*) DESCRIBE FROM WHERE Correct.

Page 2 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 16 Lesson 3 (Answer all questions in this section) 21. All computers in the world speaks the same languages, so you only need to learn one programming language - Oracle SQL. True or False? Mark for Review (1) Points

Page 38: Final Exam Oracle

True False (*) Correct. 22. There is only one kind of software used by all computers. True or Fale? Mark for Review (1) Points True False (*) Correct. Section 17 Lesson 1 (Answer all questions in this section) 23. 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 SELECT clause? Mark for Review (1) Points ONLY UNIQUE DISTINCT (*) DISTINCTROW

Page 39: Final Exam Oracle

Correct. See Section 17 24. Which of the following elements cannot be included in a WHERE clause? Mark for Review (1) Points A column alias (*) A column name A comparison condition A constant Correct. See Section 17 25. When using the LIKE condition to search for _ symbols, which character can you use as the ESCAPE option? Mark for Review (1) Points % ^ & \ (*) Correct. See Section 17 26. The Concatenation Operator does which of the following? Mark for Review (1) Points Links rows of data together inside the database.

Page 40: Final Exam Oracle

Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Correct. See Section 17 27. Which clause would you include in a SELECT statement to restrict the data returned to only the employees in department 10? Mark for Review (1) Points WHERE (*) FROM SELECT IS Correct. See Section 17 28. When using the LIKE condition, which symbol represents any sequence of none, one or more characters? Mark for Review (1) Points _ % (*) # & Correct. See Section 17

Page 41: Final Exam Oracle

Section 17 Lesson 2 (Answer all questions in this section) 29. You want to retrieve a list of customers whose last names begin with the letters Fr . Which keyword should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points AND IN BETWEEN LIKE (*) Correct. 30. You want to determine the orders that have been placed by customers who reside in Chicago . You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago;

Page 42: Final Exam Oracle

Correct.

Page 3 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 17 Lesson 2 (Answer all questions in this section) 31. You need to display all the values in the EMAIL column that contains the underscore (_) character. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? Mark for Review (1) Points The ESCAPE option (\) and one or more percent signs (%) The (+) operator A percent sign (%) The ESCAPE option (\) (*) Correct. 32. Evaluate this SQL statement:

Page 43: Final Exam Oracle

SELECT last_name, first_name, salary FROM employee;

How will the heading for the SALARY column appear in the display by default in Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 33. You need to display all the employees whose last name starts with the letters 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. Section 17 Lesson 3 (Answer all questions in this section)

Page 44: Final Exam Oracle

34. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name" FROM employees;

Which WHERE clause should you use to complete this statement? Mark for Review (1) Points WHERE email = NULL; WHERE email != NULL; WHERE email IS NULL; WHERE email IS NOT NULL; (*) Correct. 35. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAJOR_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, major_id FROM student;

Which statement is true?

Page 45: Final Exam Oracle

Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAJOR_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAJOR_ID can be displayed more than once. Each MAJOR_ID can be displayed only once. Correct. 36. If you write queries using the BETWEEN operator it does not matter in what order you enter the values, i.e. BETWEEN low value AND high value will give the same result as BETWEEN high value and low value. True or False? Mark for Review (1) Points True False (*) Correct. Section 18 Lesson 1 (Answer all questions in this section) 37. You need to replace null values in the DEPARTMENT_ID column with a zero (0). Which function should you use? Mark for Review (1) Points NVL (*)

Page 46: Final Exam Oracle

NULL NULLIF REPLACE Correct. 38. 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. 39. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct.

Page 47: Final Exam Oracle

40. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct.

Page 4 of 5

Test: Final Exam - Database Design

Review your answers, feedback, and question scores below. An asterisk (*) indicatesa correct answer.

Section 18 Lesson 1 (Answer all questions in this section) 41. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic

Page 48: Final Exam Oracle

Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 42. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points True (*) False Correct. Section 18 Lesson 2 (Answer all questions in this section) 43. 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

Page 49: Final Exam Oracle

25 (*) 10 250 (*) 100 Correct. 44. Which SELECT statement should you use to limit the display of product information 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. 45. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points

Page 50: Final Exam Oracle

The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 46. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only. The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 47. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

You need to sort data by manager id values and then alphabetically by employee lastname and first name values. Which ORDER BY clause could you use?

Page 51: Final Exam Oracle

Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 48. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. Section 18 Lesson 3

Page 52: Final Exam Oracle

(Answer all questions in this section) 49. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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;

Page 53: Final Exam Oracle

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. 50. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the tables aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct.

Page 5 of 5

Page 54: Final Exam Oracle

Section 12 Lesson 1 1. A table must have at least one candidate key, as well as its primary key. True or False? True False (*) Section 12 Lesson 1 2. The explanation below is a column integrity constraint: A column must contain only values consistent with the defined data format of the column. True or False? True (*) False Section 12 Lesson 1 3. The explanation below is a userdefined integrity rule: A primary key must be unique, and no part of the primary key can be null. True or False? True False (*) Section 12 Lesson 1 4. A table must have a primary key. True or False? True False (*) Section 12 Lesson 2 5. In a physical data model, a relationship is represented as a combination of: (Choose all correct answers) Column Primary Key or Unique Key (*) Check Constraint or Unique Key Foreign Key (*) Section 12 Lesson 2 6. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique Identifiers becomes

Columns Tables Unique Constraints (*) Primary Key Constraints Section 12 Lesson 2 7. In a physical data model, an attribute becomes a _____________. Table Foreign Key Constraint Column (*)

Page 55: Final Exam Oracle

Section 12 Lesson 3 8. Many to many relationships are implemented via a structure called a: ________________ Supertype Intersection Table (*) Intersection Entity Subtype Section 12 Lesson 3 9. What do you create when you transform a one to one relationship from your ER diagram into a physical design? Unique key constraints Intersection entity Intersection table (*) Two tables with a Foreign key constraints between them Section 12 Lesson 4 10. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? True False (*) Section 12 Lesson 4 11. Which of the following are reasons why you should consider using a Subtype Implementation? The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*) Most of the relationships are at the supertype level Section 13 Lesson 1 12. What command will return data from the database to you? FETCH GET SELECT (*) RETURN Section 13 Lesson 1 13. The DESCRIBE command returns all rows from a table. True or False? True False (*) Section 16 Lesson 1 14. Evaluate this SELECT statement:

Page 56: Final Exam Oracle

SELECT (salary * raise_percent) raise FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return? Only zeroes Only null values (*) A null value or a zero depending on the value of the SALARY column A null value or a numeric value depending on the value of the SALARY column Section 16 Lesson 1 15. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Joining only Selection only Projection only (*) Projection and Selection Section 16 Lesson 1 16. Which statement best describes how arithmetic expressions are handled? Addition operations are handled before any other operations. Multiplication and substraction operations are handled before any other operations. Multiplication and addition operations are handled before subtraction and division operations. Division and multiplication operations are handled before subtraction and addition operations. (*) Section 16 Lesson 1 17. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Projection Manipulation (*) Joining Selection Section 16 Lesson 1 18. You query the database with this SQL statement: SELECT * FROM students; Why would you use this statement? To insert data To view data (*) To display the table structure To delete data Section 16 Lesson 1 19. Which SQL statement will return an error?

SEL * FR sky; (*) select star from sky; SELECT star FROM sky;

Page 57: Final Exam Oracle

SELECT * FROM sky; Section 16 Lesson 1 20. In a SELECT clause, what is the result of 2 + 3 * 2? 6 8 (*) 10 13 Section 16 Lesson 3 21. All computers in the world speaks the same languages, so you only need to learn one programming language - Oracle SQL. True or False? True False (*) Section 16 Lesson 3 22. In a SELECT statement ADDITIONS are evaluated before Multiplications. True or False? True False (*) Section 17 Lesson 1 23. You need to display employees whose salary is in the range of 10000 through 25000 for employees in department 50 . What does the WHERE clause look like? 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 (*) Section 17 Lesson 1 24. When using the LIKE condition, which symbol represents any sequence of none, one or more characters? _ % (*) # & Section 17 Lesson 1 25. Which operator is used to combine columns of character strings to other columns? *

Page 58: Final Exam Oracle

/ + || (*) Section 17 Lesson 1 26. The Concatenation Operator does which of the following? Links rows of data together inside the database. Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Section 17 Lesson 1 27. When using the LIKE condition to search for _ symbols, which character can you use as the ESCAPE option? % ^ & \ (*) Section 17 Lesson 1 28. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? IN LIKE BETWEEN...AND... (*) IS NULL Section 17 Lesson 2 29. What will the result of the following SELECT statement be:SELECT last_name, salary, salary + 300 FROM employees;

Display the last name, salary and the results of adding 300 to each salary for all the employees (*) Modify the salary column by adding 300 and displaying the last name, salary and the new salary. Modify the salary column by adding 300 and only display the last name and the new salary. Display the last name, salary and the results of adding 300 to the salary of the first employee row Section 17 Lesson 2 30. The PLAYERS table contains these columns: PLAYER_ID NUMBER (9) Primary Key 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?

Page 59: Final Exam Oracle

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; Section 17 Lesson 2 31. Which of the following commands will display the last name concatenated with the job ID from the employees table, separated by a comma and space, and label the resulting column "Employee and Title"? SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees; SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*) SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp; SELECT last_name||","|| job_id "Employee and Title" FROM employees; Section 17 Lesson 2 32. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? = != IN (*) BETWEEN..AND.. Section 17 Lesson 2 33. You need to display all the values in the EMAIL column that contains the underscore (_) character. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? The ESCAPE option (\) and one or more percent signs (%) The (+) operator A percent sign (%) The ESCAPE option (\) (*) Section 17 Lesson 3 34. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAJOR_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, major_id FROM student;

Which statement is true? Each ADVISOR_ID can be displayed only once. Each MAJOR_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAJOR_ID can be displayed more than once. Each MAJOR_ID can be displayed only once.

Page 60: Final Exam Oracle

Section 17 Lesson 3 35. The The PRODUCT table contains these columns: PRODUCT_ID NUMBER(9) DESCRIPTION VARCHAR2(20) COST NUMBER(5,2) LOCATION_ID VARCHAR2(10)

You want to display product costs with these desired results: 1. The cost displayed for each product is increased by 10 percent. 2. The product location id must be 4859, 9789, or 9898. 3. Ten percent of the original cost is less than $10.

Which statement should you issue? SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 < 10.00 AND location_id IN (4859, 9789, 9898); (*) SELECT product_id, cost * .10 FROM product WHERE cost * 1.10 > 10.00 AND location_id IN (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * 1.10 < 10.00 AND location_id = (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 > 10.00 AND location_id = (4859, 9789, 9898); Section 17 Lesson 3 36. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name" FROM employees;

Which WHERE clause should you use to complete this statement? WHERE email = NULL; WHERE email != NULL; WHERE email IS NULL; WHERE email IS NOT NULL; (*) Section 18 Lesson 1 37. The ORDER BY clause always comes last. True or False?

Page 61: Final Exam Oracle

True (*) False Section 18 Lesson 1 38. Which statement about the default sort order is true? The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Section 18 Lesson 1 39. You need to override the default sort order of the ORDER BY clause so that the data is displayed in reverse alphabetical order. Which keyword should you include in the ORDER BY clause? DESC (*) ASC SORT CHANGE Section 18 Lesson 1 40. Which of the following are TRUE regarding the logical AND operator? TRUE AND TRUE return FALSE TRUE AND FALSE return TRUE FALSE AND TRUE return NULL TRUE AND FALSE return FALSE (*) Section 18 Lesson 1 41. From left to right, what is the correct order of Precedence? Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Section 18 Lesson 1 42. Which of the following best describes the meaning of the LIKE operator? Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Section 18 Lesson 2 43. Evaluate this SELECT statement: SELECT emp_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Page 62: Final Exam Oracle

Which clause contains an error? SELECT emp_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3; Section 18 Lesson 2 44. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR (employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200); 19 No rows will be returned. 100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*) 200, 201, 202, 203, 204, 205, 206 Section 18 Lesson 2 45. Which SELECT statement should you use to limit the display of product information to those products with a price of less than 50? 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; Section 18 Lesson 2 46. 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? SELECT product_id "Product Number", category_id "Category", price "price" ORDER BY "Product Number"; FROM products WHERE "Category" = 5570 (*) Section 18 Lesson 2 47. You need to create a report to display all employees that were hired on or 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? SELECT employee_id || - || last_name "Employee", hire_date || / || salary "Start Date and Salary" FROM employeesWHERE hire_date <= '01-JAN-96';

Page 63: Final Exam Oracle

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 employeesWHERE hire_date <= '01-JAN-96'; (*) Section 18 Lesson 2 48. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Section 18 Lesson 3 49. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you use to display the desired result? 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

Page 64: Final Exam Oracle

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; Section 18 Lesson 3 50. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Reorder the clauses in the query. (*) Remove the tables aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. 1. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct 2. An "Arc Implementation" can be done just like any other Relationship - you simply add the required Foreign Keys. True or False? Mark for Review (1) Points True False (*) Correct 3. Many to many relationships are implemented via a structure called a: ________________

Page 65: Final Exam Oracle

Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype Correct 4. It is possible to implement non-transferability via a simple Foreign Key Relationship. True or False? Mark for Review (1) Points True False (*) Correct 5. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Correct 6. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*) False Correct 7. 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 extra programming to enforce. Mark for Review (1) Points

Page 66: Final Exam Oracle

Entity integrity User-defined integrity (*) Column integrity Referential integrity Correct 8. 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 or False? Mark for Review (1) Points True False (*) Correct 9. 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 (*) Correct 10. Attributes become tables in a database. True or False? Mark for Review (1) Points True False (*) Correct

Page 1 of 5

11. Why would this table name NOT work in an Oracle database? this_year_end+next_year

Page 67: Final Exam Oracle

Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct Section 13 12. 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. 13. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True False (*) Correct. Section 16 14. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions Multiplications (*) Additions

Page 68: Final Exam Oracle

Divisions Correct. 15. You want to create a list of all albums that have been produced by the company. The list should include the title of the album, the artist's name, and the date the album was released. The ALBUMS table includes the following columns: ALB_TITLE VARCHAR2(150) NOT NULL ALB_ARTIST VARCHAR2(150) NOT NULL ALB_DATE DATE NOT NULL

Which statement can you use to retrieve the necessary information?

Mark for Review (1) Points SELECT * FROM albums;(*) SELECT alb_title, alb_artist, alb_dates FROM album; SELECT alb_title, alb_artist, alb_dates FROM albums; SELECT alb_title; alb_artist; alb_date FROM albums; Correct. 16. In which clause of a SELECT statement would you specify the name of the table 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 SELECT statement. Correct. 17. Which SQL keyword specifies that an alias will be substituted for a column name in the output of a SQL query? Mark for Review (1) Points

Page 69: Final Exam Oracle

AS (*) OR AND SUBSTITUTE Correct. 18. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review (1) Points 6 8 (*) 10 13 Correct. 19. 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.

Page 70: Final Exam Oracle

Incorrect. See Section 16 20. Which SQL statement will return an error? Mark for Review (1) Points SEL * FR sky; (*) select star from sky; SELECT star FROM sky; SELECT * FROM sky; Correct.

Page 2 of 5

21. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct 22. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Correct Section 17 23. The PRODUCT table contains these columns: PRODUCT_ID NUMBER(9) DESCRIPTION VARCHAR2(20) COST NUMBER(5,2)

Page 71: Final Exam Oracle

LOCATION_ID VARCHAR2(10)

You want to display product costs with these desired results: 1. The cost displayed for each product is increased by 10 percent. 2. The product location id must be 4859, 9789, or 9898. 3. Ten percent of the original cost is less than $10. Which statement should you issue? Mark for Review (1) Points SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 < 10.00 AND location_id IN (4859, 9789, 9898); (*) SELECT product_id, cost * .10 FROM product WHERE cost * 1.10 > 10.00 AND location_id IN (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * 1.10 < 10.00 AND location_id = (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 > 10.00 AND location_id = (4859, 9789, 9898); Correct. See Section 17 24. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name" FROM employees;

Which WHERE clause should you use to complete this statement? Mark for Review (1) Points WHERE email = NULL; WHERE email != NULL; WHERE email IS NULL; WHERE email IS NOT NULL; (*)

Page 72: Final Exam Oracle

Correct. 25. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAIN_SUBJECT_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, main_subject_id FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAIN_SUBJECT_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAIN_SUBJECT_ID can be displayed more than once. Each MAIN_SUBJECT_ID can be displayed only once per query. Correct. See Section 17 26. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct. 27. 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 SELECT clause? Mark for Review (1) Points ONLY UNIQUE DISTINCT (*) DISTINCTROW

Page 73: Final Exam Oracle

Correct. See Section 17 28. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES table and display the columns as a combined character string. Which operator should you use? Markfor Review (1) Points + | || (*) AND Correct. See Section 17 29. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. 30. When using the LIKE condition to search for _ symbols, which character can you use as the default ESCAPE option? Mark for Review (1) Points % ^ & \ (*) Correct.

Page 3 of 5

31. Which of the following elements cannot be included in a WHERE clause? Mark for Review (1) Points

Page 74: Final Exam Oracle

A column alias (*) A column name A comparison condition A constant Correct. 32. Evaluate this SELECT statement: SELECT * FROM employeesWHERE department_id IN(10, 20, 30) AND salary > 20000;

Which values would cause the logical condition to return TRUE? Mark for Review (1) Points DEPARTMENT_ID = 10 and SALARY = 20000 DEPARTMENT_ID = 20 and SALARY = 20000 DEPARTMENT_ID = null and SALARY = 20001 DEPARTMENT_ID = 10 and SALARY = 20001 (*) Correct. See Section 17 33. You want to retrieve a list of customers whose last names begin with the letters Fr . Which keyword should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points AND IN BETWEEN LIKE (*) Correct. See Section 17 34. You want to determine the orders that have been placed by customers who reside in Chicago. You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points

Page 75: Final Exam Oracle

AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago; Correct. 35. 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 Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 36. You need to display all the values in the EMAIL column that contains the underscore (_) character as part of that email address. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? Mark for Review (1) Points The ESCAPE option (\) and one or more percent signs (%) The (+) operator A percent sign (%) The ESCAPE option (\) (*) Correct. See Section 17 Section 18 37. Which of the following is TRUE regarding the logical AND operator? Mark for Review (1) Points TRUE AND TRUE return FALSE

Page 76: Final Exam Oracle

TRUE AND FALSE return TRUE FALSE AND TRUE return NULL TRUE AND FALSE return FALSE (*) Correct. 38. 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 include in the ORDER BY clause? Mark for Review (1) Points DESC (*) ASC SORT CHANGE Correct. 39. 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. 40. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct.

Page 77: Final Exam Oracle

Page 4 of 5

41. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Correct. 42. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct. 43. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. 44. 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);

Page 78: Final Exam Oracle

Which two values could the statement return? (Choose two.) Mark for Review (1) Points (Choose all correct answers) 1 50 25 (*) 10 250 (*) 100 Correct. 45. You need to create a report to display all employees that were hired on or 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 employeesWHERE 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

Page 79: Final Exam Oracle

WHERE hire_date <= '01-JAN-96'; (*) Incorrect! See Section 18. 46. 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. 47. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 48. Evaluate this SELECT statement: SELECT last_name, first_name, email FROM employees ORDER BY email;

If the EMAIL column contains null values, which statement is true? Mark for Review (1) Points

Page 80: Final Exam Oracle

Null email values will be displayed first in the result. Null email values will be displayed last in the result. (*) Null email values will not be displayed in the result. The result will not be sorted. Correct. 49. 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 the players names to be displayed alphabetically by last name and then by first name. 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. 50. The PLAYERS table contains these columns: PLAYERS TABLE: LAST_NAME VARCHAR2 (20)

Page 81: Final Exam Oracle

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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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.

Page 5 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12

Page 82: Final Exam Oracle

1. The text below is an example of what constraint type:The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 2. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*) False Correct 3. Entity integrity refers to Mark for Review (1) Points Tables always containing text data Tables always containing numeric data Columns having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. Tables having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. (*) Correct 4. 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 or False? Mark for Review (1) Points True False (*)

Page 83: Final Exam Oracle

Correct 5. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique Identifiers become Mark for Review (1) Points Columns Tables Unique Constraints (*) Primary Key Constraints Correct 6. Why would this table name NOT work in an Oracle database? this_year_end+next_year Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct 7. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key Constraint Column (*) Correct 8. The Oracle Database can implement a many to many relationship. You simply create two foreign keys between the two tables. True or False? Mark for Review (1) Points True False (*)

Page 84: Final Exam Oracle

Correct 9. What do you create when you transform a many to many relationship from your ER diagram into a physical design? Mark for Review (1) Points Unique key constraints Intersection entity Intersection table (*) Two tables with Foreign key constraints between them Correct 10. An "Arc Implementation" can be done just like any other Relationship - you simply add the required Foreign Keys. True or False? Mark for Review (1) Points True False (*) Correct

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12 11. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct

Page 85: Final Exam Oracle

Section 13 12. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct. 13. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. Section 16 14. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions Multiplications (*) Additions Divisions Correct. 15. You want to create a list of all albums that have been produced by the company. The list should include the title of the album, the artist's name, and the date the album was released. The ALBUMS table includes the following columns: ALB_TITLE VARCHAR2(150) NOT NULL ALB_ARTIST VARCHAR2(150) NOT NULL

Page 86: Final Exam Oracle

ALB_DATE DATE NOT NULL

Which statement can you use to retrieve the necessary information?

Mark for Review (1) Points SELECT * FROM albums;(*) SELECT alb_title, alb_artist, alb_dates FROM album; SELECT alb_title, alb_artist, alb_dates FROM albums; SELECT alb_title; alb_artist; alb_date FROM albums; Correct. 16. What would you use in the SELECT clause to return all the columns in the table? Mark forReview (1) Points An asterisk (*) (*) A minus sign (-) A plus sign (+) The ALL keyword Correct. 17. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct.

Page 87: Final Exam Oracle

18. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review (1) Points 6 8 (*) 10 13 Correct. 19. 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. Incorrect. See Section 16 20. If a SQL statement returns data from two or more tables, which SQL capability is being used? Mark for Review (1) Points Selection Projection

Page 88: Final Exam Oracle

Joining (*) Insertion Correct. Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 16 21. Would it be a good idea to model age as an attribute of STUDENT? Mark for Review (1) Points Yes Maybe it could stop us having to calculate someone's age every time we need it Sometimes No - it breaks the Normalization rules (*) Correct 22. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Correct Section 17 23. 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 first names, last names and hire dates of those employees who were hired between March 1, 2000, and August 30, 2000. Which statements can you issue to accomplish this task?

Page 89: Final Exam Oracle

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'; Incorrect. See Section 17. 24. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name" FROM employees;

Which WHERE clause should you use to complete this statement? Mark for Review (1) Points WHERE email = NULL; WHERE email != NULL; WHERE email IS NULL; WHERE email IS NOT NULL; (*) Correct. 25. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) PrimaryKey LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20)

Page 90: Final Exam Oracle

DEPARTMENT_ID NUMBER(5) NOT NULL MANAGER_ID NUMBER(9) NOT NULL

Evaluate these two SELECT statements: 1. SELECT DISTINCT employee_id, department_id, manager_id FROM employees; 2. SELECT employee_id, department_id, manager_id FROM employees;

Which of the following statements is true? Mark for Review (1) Points The two statements will display the same data. (*) The first statement will display a particular DEPARTMENT_ID only once. The first statement will NOT display values from all of the rows in the EMPLOYEES table The second statement could display a unique combination of the EMPLOYEE_ID, MANAGER_ID, and DEPARTMENT_ID values more than once. Incorrect. See Section 17 26. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND.. Correct. 27. Evaluate this SELECT statement: SELECT * FROM employeesWHERE department_id IN(10, 20, 30) AND salary > 20000;

Which values would cause the logical condition to return TRUE? Mark for Review (1) Points DEPARTMENT_ID = 10 and SALARY = 20000 DEPARTMENT_ID = 20 and SALARY = 20000 DEPARTMENT_ID = null and SALARY = 20001 DEPARTMENT_ID = 10 and SALARY = 20001 (*)

Page 91: Final Exam Oracle

Correct. See Section 17 28. You want to determine the orders that have been placed by customers who reside in Chicago. You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago; Correct. 29. If the EMPLOYEES table has the following columns, and you want to write a SELECT statement to return the employee last name and department number for employee number 176, which of the following SQL statements should you use? Name Type Length EMPLOYEE_ID NUMBER 22 FIRST_NAME VARCHAR2 20 LAST_NAME VARCHAR2 25 EMAIL VARCHAR2 25 PHONE_NUMBER VARCHAR2 20 SALARY NUMBER 22 COMMISSION_PCT NUMBER 22 MANAGER_ID NUMBER 22 DEPARTMENT_ID NUMBER 22

Mark for Review (1) Points SELECT last_name, department_id FROM employees WHERE employee_id = 176; (*) SELECT last_name, department_id FROM employees WHERE employee_id equals 176; SELECT first_name, employee_id FROM employees WHERE employee_id = 176;

Page 92: Final Exam Oracle

SELECT last_name, employee_id FROM employees WHERE employee_id equals 176; Correct. 30. You need to display all the employees whose last name starts with the letters 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. See Section 17 Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 17 31. Which statement best describes how column headings are displayed by default in Oracle Application Express: Mark for Review (1) Points Column headings are displayed left-justified and in lowercase. Column headings are displayed left-justified and in uppercase. Column headings are displayed centered and in uppercase. (*) Column headings are displayed centered and in mixed case. Correct. See Section 17 32. You need to display employees with salaries that are at least 30000 or higher. Which comparison operator should you use? Mark for Review (1) Points > "=>"

Page 93: Final Exam Oracle

>= (*) != Correct. 33. You need to display employees whose salary is in the range of 10000 through 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. 34. When using the LIKE condition to search for _ symbols, which character can you use as the default ESCAPE option? Mark for Review (1) Points % ^ & \ (*) Correct. 35. What does the DISTINCT keyword do when it is used in a SELECT clause? Mark for Review(1) Points Hides NULL values Eliminates all unique values and compares values Eliminates duplicate rows in the result (*)

Page 94: Final Exam Oracle

Eliminates only unique rows in the result Correct. See Section 17 36. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? Mark for Review (1) Points IN LIKE BETWEEN...AND... (*) IS NULL Correct. Section 18 37. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct. 38. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Incorrect. See Section 18 39. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points

Page 95: Final Exam Oracle

True (*) False Correct. 40. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Correct. Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 18 41. Which of the following is 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. 42. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical

Page 96: Final Exam Oracle

Correct. 43. 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 the players names to be displayed alphabetically by last name and then by first name. 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. 44. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you use to display the desired result?

Page 97: Final Exam Oracle

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. 45. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 46. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id

Page 98: Final Exam Oracle

FROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 47. 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 statement? Mark for Review (1) Points IN (*) AND LIKE BETWEEN ... AND ... Correct. 48. 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 (*)

Page 99: Final Exam Oracle

10 250 (*) 100 Correct. 49. 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. 50. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct.

1. What do you create when you transform a many to many relationship from your ER diagraminto a physical design? Mark for Review (1) Points

Page 100: Final Exam Oracle

Unique key constraints Intersection entity Intersection table (*) Two tables with Foreign key constraints between them Correct 2. The Oracle Database can implement a many to many relationship. You simply create two foreign keys between the two tables. True or False? Mark for Review (1) Points True False (*) Correct 3. The transformation from an ER diagram to a physical design involves changing terminology. Primary Unique Identifiers in the ER diagram become __________ and relationships become ____________. Mark for Review (1) Points Foreign keys, Primary keys Primary keys, Foreign keys (*) Foreign keys, mandatory business rules Unique Keys, Primary keys Correct 4. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key Constraint Column (*) Correct 5. Attributes become tables in a database. True or False? Mark for Review (1) Points

Page 101: Final Exam Oracle

True False (*) Correct 6. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct 7. When translating an arc relationship to a physical design, you must turn the arc relationships into foreign keys. Assuming you are implementing an Exclusive Design, you must also create two Unique Key Constraints to ensure the Arc is implemented correctly. True or False? Mark for Review (1) Points True False (*) Correct 8. 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 or False? Mark for Review (1) Points True False (*) Correct 9. A table must have at least one candidate key, as well as its primary key. True or False? Mark for Review (1) Points True False (*) Correct

Page 102: Final Exam Oracle

10. If a primary key is a set of columns then one column must be null. True or False? Mark forReview (1) Points True False (*) Correct 11. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct Section 13 12. 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. 13. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct.

Page 103: Final Exam Oracle

Section 16 14. Which SQL statement will return an error? Mark for Review (1) Points SEL * FR sky; (*) select star from sky; SELECT star FROM sky; SELECT * FROM sky; Correct. 15. You query the database with this SQL statement: SELECT * FROM transaction WHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*) Projection only Selection and projection only Projection, selection and joining Incorrect. See Section 16 16. 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.

Page 104: Final Exam Oracle

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. Incorrect. See Section 16 17. You query the database with this SQL statement: SELECT * FROM students;

Why would you use this statement? Mark for Review (1) Points To insert data To view data (*) To display the table structure To delete data Correct. 18. Which statement best describes how arithmetic expressions are handled? Mark for Review (1) Points Addition operations are handled before any other operations. Multiplication and subtraction operations are handled before any other operations. Multiplication and addition operations are handled before subtraction and division operations. Division and multiplication operations are handled before subtraction and addition operations. (*) Correct. 19. In a SQL statement, which clause specifies one or more columns to be returned by the query? Mark for Review (1) Points

Page 105: Final Exam Oracle

SELECT (*) FROM WHERE Any of the above options, you can list columns wherever you want to in a SELECT statement. Correct. 20. Which SQL keyword specifies that an alias will be substituted for a column name in the output of a SQL query? Mark for Review (1) Points AS (*) OR AND SUBSTITUTE Correct. 21. Would it be a good idea to model age as an attribute of STUDENT? Mark for Review (1) Points Yes Maybe it could stop us having to calculate someone's age every time we need it Sometimes No - it breaks the Normalization rules (*) Correct 22. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct

Page 106: Final Exam Oracle

Section 17 23. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAIN_SUBJECT_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, main_subject_id FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAIN_SUBJECT_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAIN_SUBJECT_ID can be displayed more than once. Each MAIN_SUBJECT_ID can be displayed only once per query. Correct. See Section 17 24. 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 first names, last names and hire dates of those employees who were hired between March 1, 2000, and August 30, 2000. 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';

Page 107: Final Exam Oracle

SELECT last_name, first_name, hire_date FROM employees AND hire_date >= '01-MAR-00' and hire_date <= '30-AUG- 00'; Incorrect. See Section 17. 25. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name" FROM employees;

Which WHERE clause should you use to complete this statement? Mark for Review (1) Points WHERE email = NULL; WHERE email != NULL; WHERE email IS NULL; WHERE email IS NOT NULL; (*) Correct. 26. Which of the following commands will display the last name concatenated with the job ID from the employees table, separated by a comma and space, and label the resulting column "Employee and Title"? Mark for Review (1) Points SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees; SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*) SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp; SELECT last_name||","|| job_id "Employee and Title" FROM employees; Correct. See Section 17 27. Which SELECT statement will display both unique and non-unique combinations of the MANAGER_ID and DEPARTMENT_ID values from the EMPLOYEES table? Mark for Review (1) Points SELECT manager_id, department_id DISTINCT FROM employees;

Page 108: Final Exam Oracle

SELECT manager_id, department_id FROM employees; (*) SELECT DISTINCT manager_id, department_id FROM employees; SELECT manager_id, DISTINCT department_id FROM employees; Incorrect. See Section 17. 28. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND.. Correct. 29. 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 Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 30. You need to display all the employees whose last name starts with the letters 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_'

Page 109: Final Exam Oracle

Correct. See Section 17

31. Which comparison condition would you use to select rows that match a character pattern? Mark for Review (1) Points IN LIKE (*) ALMOST SIMILAR Correct. 32. Which clause would you include in a SELECT statement to restrict the data returned to only the employees in department 10? Mark for Review (1) Points WHERE (*) FROM SELECT IS Correct. 33. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. 34. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND...

Page 110: Final Exam Oracle

IS NULL Correct. 35. When using the LIKE condition, which symbol represents any sequence of none, one or more characters? Mark for Review (1) Points _ % (*) # & Correct. 36. Which symbol represents the not equal to condition? Mark for Review (1) Points # '+' != (*) ~ Correct. Section 18 37. Evaluate this SELECT statement: SELECT employee_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Which clause contains an error? Mark for Review (1) Points SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Page 111: Final Exam Oracle

Correct. 38. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only. The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 39. You need to create a report to display all employees that were hired on or 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 employeesWHERE 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';

Page 112: Final Exam Oracle

SELECT employee_id ||' - '|| last_name "Employee", hire_date ||' / '|| salary "Start Date and Salary" FROM employeesWHERE hire_date <= '01-JAN-96'; (*) Incorrect! See Section 18. 40. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 41. 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 statement? Mark for Review (1) Points IN (*) AND LIKE BETWEEN ... AND ... Correct. 42. You query the database with this SQL statement: SELECT price FROM products WHERE price IN(1, 25, 50, 250)

Page 113: Final Exam Oracle

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 (*) 100 Correct. 43. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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;

Page 114: Final Exam Oracle

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. 44. 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 the players names to be displayed alphabetically by last name and then by first name. 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. 45. 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 include in the ORDER BY clause? Mark for Review

Page 115: Final Exam Oracle

(1) Points DESC (*) ASC SORT CHANGE Correct. 46. 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. 47. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points True (*) False Correct. 48. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Correct. 49. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*)

Page 116: Final Exam Oracle

NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 50. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Incorrect. See Section 18

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12 1. Why would this table name NOT work in an Oracle database? this_year_end+next_year Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct 2. 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

Page 117: Final Exam Oracle

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 Incorrect. Refer to Section 12 3. Attributes become tables in a database. True or False? Mark for Review (1) Points True False (*) Correct 4. 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 or False? Mark for Review (1) Points True False (*) Correct 5. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Correct 6. The text below is an example of what constraint type:The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity

Page 118: Final Exam Oracle

Referential integrity (*) Correct 7. Foreign keys must be null. True or False? Mark for Review (1) Points True False (*) Correct 8. When translating an arc relationship to a physical design, you must turn the arc relationships into foreign keys. Assuming you are implementing an Exclusive Design, you must also create two Unique Key Constraints to ensure the Arc is implemented correctly. True or False? Mark for Review (1) Points True False (*) Correct 9. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct 10. The Oracle Database can implement a many to many relationship. You simply create two foreign keys between the two tables. True or False? Mark for Review (1) Points True False (*) Correct

Page 1 of 5

Page 119: Final Exam Oracle

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12 11. Many to many relationships are implemented via a structure called a: ________________ Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype Correct Section 13 12. 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. 13. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True

Page 120: Final Exam Oracle

False (*) Correct. Section 16 14. Would it be a good idea to model age as an attribute of STUDENT? Mark for Review (1) Points Yes Maybe it could stop us having to calculate someone's age every time we need it Sometimes No - it breaks the Normalization rules (*) Correct 15. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct 16. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct. 17. What would you use in the SELECT clause to return all the columns in the table? Mark forReview

Page 121: Final Exam Oracle

(1) Points An asterisk (*) (*) A minus sign (-) A plus sign (+) The ALL keyword Correct. 18. Evaluate this SELECT statement: SELECT (salary * raise_percent) raise FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return? Mark for Review (1) Points Only zeroes Only null values (*) A null value or a zero depending on the value of the SALARY column A null value or a numeric value depending on the value of the SALARY column Correct. 19. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions Multiplications (*) Additions Divisions Correct. 20. In which clause of a SELECT statement would you specify the name of the table or tables being queried? Mark for Review (1) Points The FROM clause (*) The SELECT clause The WHERE clause

Page 122: Final Exam Oracle

Any of the above options, you can list tables wherever you want to in a SELECT statement. Correct.

Page 2 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 16 21. Which SQL keyword specifies that an alias will be substituted for a column name in the output of a SQL query? Mark for Review (1) Points AS (*) OR AND SUBSTITUTE Correct. 22. You query the database with this SQL statement: SELECT * FROM transaction WHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*) Projection only Selection and projection only Projection, selection and joining

Page 123: Final Exam Oracle

Correct. Section 17 23. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct. 24. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? Mark for Review (1) Points IN LIKE BETWEEN...AND... (*) IS NULL Correct. 25. Which comparison condition would you use to select rows that match a character pattern? Mark for Review (1) Points IN LIKE (*) ALMOST SIMILAR Correct. 26. The Concatenation Operator does which of the following? Mark for Review (1) Points Links rows of data together inside the database.

Page 124: Final Exam Oracle

Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Correct. See Section 17 27. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES table and display the columns as a combined character string. Which operator should you use? Markfor Review (1) Points + | || (*) AND Correct. See Section 17 28. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. 29. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAIN_SUBJECT_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, main_subject_id FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once.

Page 125: Final Exam Oracle

Each MAIN_SUBJECT_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAIN_SUBJECT_ID can be displayed more than once. Each MAIN_SUBJECT_ID can be displayed only once per query. Correct. See Section 17 30. 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 first names, last names and hire dates of those employees who were hired between March 1, 2000, and August 30, 2000. 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.

Page 3 of 5

Test: Final Exam Semester 1

Page 126: Final Exam Oracle

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 17 31. The PRODUCT table contains these columns: PRODUCT_ID NUMBER(9) DESCRIPTION VARCHAR2(20) COST NUMBER(5,2) LOCATION_ID VARCHAR2(10)

You want to display product costs with these desired results: 1. The cost displayed for each product is increased by 10 percent. 2. The product location id must be 4859, 9789, or 9898. 3. Ten percent of the original cost is less than $10. Which statement should you issue? Mark for Review (1) Points SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 < 10.00 AND location_id IN (4859, 9789, 9898); (*) SELECT product_id, cost * .10 FROM product WHERE cost * 1.10 > 10.00 AND location_id IN (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * 1.10 < 10.00 AND location_id = (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 > 10.00 AND location_id = (4859, 9789, 9898); Correct. See Section 17 32. You want to determine the orders that have been placed by customers who reside in Chicago. You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points

Page 127: Final Exam Oracle

AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago; Correct. 33. You need to display all the employees whose last name starts with the letters 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. See Section 17 34. Evaluate this SELECT statement: SELECT * FROM employeesWHERE department_id IN(10, 20, 30) AND salary > 20000;

Which values would cause the logical condition to return TRUE? Mark for Review (1) Points DEPARTMENT_ID = 10 and SALARY = 20000 DEPARTMENT_ID = 20 and SALARY = 20000 DEPARTMENT_ID = null and SALARY = 20001 DEPARTMENT_ID = 10 and SALARY = 20001 (*) Correct. See Section 17 35. You need to display all the values in the EMAIL column that contains the underscore (_) character as part of that email address. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? Mark for Review (1) Points The ESCAPE option (\) and one or more percent signs (%) The (+) operator

Page 128: Final Exam Oracle

A percent sign (%) The ESCAPE option (\) (*) Correct. See Section 17 36. 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 Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. Section 18 37. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Correct. 38. Which logical operator returns TRUE if either condition is true? Mark for Review (1) Points OR (*) AND NOT BOTH

Page 129: Final Exam Oracle

Correct. 39. Which clause would you include in a SELECT statement to sort the rows returned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct. 40. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct.

Page 4 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 18 41. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values.

Page 130: Final Exam Oracle

To test for values in a list. Match a character pattern. (*) To find Null values. Correct. 42. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 43. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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

Page 131: Final Exam Oracle

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. 44. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct. 45. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200);

Mark for Review (1) Points 19 No rows will be returned 100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*) 200, 201, 202, 203, 204, 205, 206 Correct. 46. Evaluate this SELECT statement:

Page 132: Final Exam Oracle

SELECT last_name, first_name, email FROM employees ORDER BY email;

If the EMAIL column contains null values, which statement is true? Mark for Review (1) Points Null email values will be displayed first in the result. Null email values will be displayed last in the result. (*) Null email values will not be displayed in the result. The result will not be sorted. Correct. 47. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only. The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 48. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name

Page 133: Final Exam Oracle

Correct. 49. 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 (*) 100 Correct. 50. Which SELECT statement should you use to limit the display of product information 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

Page 134: Final Exam Oracle

GROUP BY price; Correct.

Page 5 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12 1. What do you create when you transform a many to many relationship from your ER diagram into a physical design? Mark for Review (1) Points Unique key constraints Intersection entity Intersection table (*) Two tables with Foreign key constraints between them Correct 2. Many to many relationships are implemented via a structure called a: ________________ Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype Correct

Page 135: Final Exam Oracle

3. An "Arc Implementation" can be done just like any other Relationship - you simply add the required Foreign Keys. True or False? Mark for Review (1) Points True False (*) Correct 4. When translating an arc relationship to a physical design, you must turn the arc relationships into foreign keys. Assuming you are implementing an Exclusive Design, you must also create two Unique Key Constraints to ensure the Arc is implemented correctly. True or False? Mark for Review (1) Points True False (*) Correct 5. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 6. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 12 7. Identify all of the incorrect statements that complete this sentence: A primary key is: (Choose three) Mark for Review (1) Points (Choose all correct answers) A single column that uniquely identifies each column in a table (*)

Page 136: Final Exam Oracle

One or more columns in a table that uniquely identifies each row in that table A set of columns in one table that uniquely identifies each row in another table (*) Only one column that must be null (*) Correct 8. 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 or False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 12 9. The transformation from an ER diagram to a physical design involves changing terminology. Primary Unique Identifiers in the ER diagram become __________ and relationships become ____________. Mark for Review (1) Points Foreign keys, Primary keys Primary keys, Foreign keys (*) Foreign keys, mandatory business rules Unique Keys, Primary keys Correct 10. Why would this table name NOT work in an Oracle database? this_year_end+next_year Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct

Page 1 of 5

Page 137: Final Exam Oracle

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 12 11. 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 Incorrect. Refer to Section 12 Section 13 12. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. 13. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*)

Page 138: Final Exam Oracle

EVERY Correct. Section 16 14. In which clause of a SELECT statement would you specify the name of the table 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 SELECT statement. Correct. 15. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review (1) Points 6 8 (*) 10 13 Correct. 16. What would you use in the SELECT clause to return all the columns in the table? Mark forReview (1) Points An asterisk (*) (*) A minus sign (-) A plus sign (+) The ALL keyword Correct. 17. In the default order of precedence, which operator would be evaluated first? Mark for Review

Page 139: Final Exam Oracle

(1) Points Subtractions Multiplications (*) Additions Divisions Correct. 18. You query the database with this SQL statement: SELECT * FROM students;

Why would you use this statement? Mark for Review (1) Points To insert data To view data (*) To display the table structure To delete data Correct. 19. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection Correct. 20. If a SQL statement returns data from two or more tables, which SQL capability is being used? Mark for Review (1) Points Selection Projection Joining (*)

Page 140: Final Exam Oracle

Insertion Correct.

Page 2 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 16 21. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Incorrect. Refer to Section 6 22. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct Section 17 23. You want to retrieve a list of customers whose last names begin with the letters Fr . Which keyword should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points

Page 141: Final Exam Oracle

AND IN BETWEEN LIKE (*) Correct. See Section 17 24. You want to retrieve a list of customers whose last names begin with the letters Fr . Which symbol should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points % (*) ~ # * Correct. See Section 17 25. If the EMPLOYEES table has the following columns, and you want to write a SELECT statement to return the employee last name and department number for employee number 176, which of the following SQL statements should you use? Name Type Length EMPLOYEE_ID NUMBER 22 FIRST_NAME VARCHAR2 20 LAST_NAME VARCHAR2 25 EMAIL VARCHAR2 25 PHONE_NUMBER VARCHAR2 20 SALARY NUMBER 22 COMMISSION_PCT NUMBER 22 MANAGER_ID NUMBER 22 DEPARTMENT_ID NUMBER 22

Mark for Review (1) Points SELECT last_name, department_id FROM employees WHERE employee_id = 176; (*) SELECT last_name, department_id FROM employees WHERE employee_id equals 176; SELECT first_name, employee_id

Page 142: Final Exam Oracle

FROM employees WHERE employee_id = 176; SELECT last_name, employee_id FROM employees WHERE employee_id equals 176; Correct. 26. You need to display all the employees whose last name starts with the letters 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. See Section 17 27. You want to determine the orders that have been placed by customers who reside in Chicago. You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago; Correct. 28. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAIN_SUBJECT_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, main_subject_id

Page 143: Final Exam Oracle

FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAIN_SUBJECT_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAIN_SUBJECT_ID can be displayed more than once. Each MAIN_SUBJECT_ID can be displayed only once per query. Correct. See Section 17 29. You want to create a report that displays all employees who were hired before January 1, 2000 and whose annual salaries are greater than 50000. The EMPLOYEES table contains these columns:

EMPLOYEE_ID VARCHAR2(5) PRIMARY KEY LAST_NAME VARCHAR2(35) HIREDATE DATE DEPARTMENT_ID NUMBER(4)

The SALARY table contains these columns:

SALARYID VARCHAR2(5) PRIMARY KEY SALARY NUMBER(5, 2) EMPLOYEE_ID VARCHAR2(5) FOREIGN KEY

Which query should you issue? Mark for Review (1) Points SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary USING employee_id WHERE hiredate < 01-jan-00 AND salary > 50000; SELECT last_name, hiredate, salary FROM employees JOIN salary ON employee_id = employee_id WHERE hiredate < '01-jan-00' AND salary > 50000; SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary WHERE hiredate < '01-jan-00' AND salary > 50000; (*) SELECT last_name, hiredate, salary FROM employees (+) salary WHERE hiredate < '01-jan-00' AND salary > 50000;

Page 144: Final Exam Oracle

Incorrect 30. 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 first names, last names and hire dates of those employees who were hired between March 1, 2000, and August 30, 2000. 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.

Page 3 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Section 17 31. Which of the following elements cannot be included in a WHERE clause? Mark for Review(1) Points

Page 145: Final Exam Oracle

A column alias (*) A column name A comparison condition A constant Correct. 32. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct. 33. The Concatenation Operator does which of the following? Mark for Review (1) Points Links rows of data together inside the database. Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Correct. See Section 17 34. You need to display employees whose salary is in the range of 10000 through 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

Page 146: Final Exam Oracle

WHERE department_id = 50 AND salary BETWEEN 25000 AND 10000 (*) Correct. 35. Which operator is used to combine columns of character strings to other columns? Mark for Review (1) Points * / + || (*) Correct. See Section 17 36. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. Section 18 37. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct.

Page 147: Final Exam Oracle

38. Which clause would you include in a SELECT statement to sort the rows returned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct. 39. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 40. Which comparison condition means "Less Than or Equal To?" Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct.

Page 4 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Term Exam covers Sections 11-18 of Database Design.

Page 148: Final Exam Oracle

Section 18 41. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points True (*) False Correct. 42. 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. 43. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200);

Mark for Review (1) Points 19 No rows will be returned 100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*) 200, 201, 202, 203, 204, 205, 206 Correct. 44. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points

Page 149: Final Exam Oracle

The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 45. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. 46. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only. The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 47. Which SELECT statement should you use to limit the display of product information to those products with a price of less than 50? Mark for Review (1) Points

Page 150: Final Exam Oracle

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. 48. Evaluate this SELECT statement: SELECT employee_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Which clause contains an error? Mark for Review (1) Points SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3; Incorrect! See Section 18. 49. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

Page 151: Final Exam Oracle

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct. 50. 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 the players names to be displayed alphabetically by last name and then by first name. 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.

Page 152: Final Exam Oracle

Page 5 of 5

Section 12 1. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct 2. An "Arc Implementation" can be done just like any other Relationship - you simply add the required Foreign Keys. True or False? Mark for Review (1) Points True False (*) Correct 3. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*) False Correct 4. 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 extra programming to enforce. Mark for Review (1) Points Entity integrity User-defined integrity (*)

Page 153: Final Exam Oracle

Column integrity Referential integrity Correct 5. The text below is an example of what constraint type:The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 6. A table must have at least one candidate key, as well as its primary key. True or False? Mark for Review (1) Points True False (*) Correct 7. Many to many relationships are implemented via a structure called a: ________________ Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype Correct 8. It is possible to implement non-transferability via a simple Foreign Key Relationship. True or False? Mark for Review (1) Points True

Page 154: Final Exam Oracle

False (*) Correct 9. 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 (*) Correct 10. The transformation from an ER diagram to a physical design involves changing terminology. Primary Unique Identifiers in the ER diagram become __________ and relationships become ____________. Mark for Review (1) Points Foreign keys, Primary keys Primary keys, Foreign keys (*) Foreign keys, mandatory business rules Unique Keys, Primary keys Correct

Section 12 11. 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 Incorrect. Refer to Section 12

Page 155: Final Exam Oracle

Section 13 12. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct. 13. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True False (*) Correct. Section 16 14. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Correct 15. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above.

Page 156: Final Exam Oracle

Correct 16. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review (1) Points 6 8 (*) 10 13 Correct. 17. You query the database with this SQL statement: SELECT * FROM transaction WHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*) Projection only Selection and projection only Projection, selection and joining Incorrect. See Section 16 18. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct. 19. When listing columns in the SELECT list, what should you use to separate the columns? Mark for Review (1) Points

Page 157: Final Exam Oracle

Commas (*) Semicolons Dashes Underscores Correct. 20. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection Correct. 21. Evaluate this SELECT statement: SELECT (salary * raise_percent) raise FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return? Mark for Review (1) Points Only zeroes Only null values (*) A null value or a zero depending on the value of the SALARY column A null value or a numeric value depending on the value of the SALARY column Correct. 22. If a SQL statement returns data from two or more tables, which SQL capability is being used? Mark for Review (1) Points Selection Projection Joining (*) Insertion

Page 158: Final Exam Oracle

Correct. Section 17 23. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) PrimaryKey LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) DEPARTMENT_ID NUMBER(5) NOT NULL MANAGER_ID NUMBER(9) NOT NULL

Evaluate these two SELECT statements: 1. SELECT DISTINCT employee_id, department_id, manager_id FROM employees; 2. SELECT employee_id, department_id, manager_id FROM employees;

Which of the following statements is true? Mark for Review (1) Points The two statements will display the same data. (*) The first statement will display a particular DEPARTMENT_ID only once. The first statement will NOT display values from all of the rows in the EMPLOYEES table The second statement could display a unique combination of the EMPLOYEE_ID, MANAGER_ID, and DEPARTMENT_ID values more than once. Incorrect. See Section 17 24. The STUDENT table contains these columns: STUDENT_ID NUMBER(10) Primary Key LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MAIN_SUBJECT_ID NUMBER(3) ADVISOR_ID NUMBER(5)

Evaluate this statement: SELECT DISTINCT advisor_id, main_subject_id FROM student;

Which statement is true? Mark for Review (1) Points Each ADVISOR_ID can be displayed only once. Each MAIN_SUBJECT_ID can be displayed more than once per ADVISOR_ID. (*) Each combination of ADVISOR_ID and MAIN_SUBJECT_ID can be displayed more than once. Each MAIN_SUBJECT_ID can be displayed only once per query.

Page 159: Final Exam Oracle

Correct. See Section 17 25. If you write queries using the BETWEEN operator it does not matter in what order you enter the values, i.e. BETWEEN low value AND high value will give the same result as BETWEENhigh value and low value. True or False? Mark for Review (1) Points True False (*) Correct. 26. 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. 27. Evaluate this SELECT statement: SELECT * FROM employeesWHERE department_id IN(10, 20, 30) AND salary > 20000;

Which values would cause the logical condition to return TRUE? Mark for Review (1) Points DEPARTMENT_ID = 10 and SALARY = 20000 DEPARTMENT_ID = 20 and SALARY = 20000 DEPARTMENT_ID = null and SALARY = 20001

Page 160: Final Exam Oracle

DEPARTMENT_ID = 10 and SALARY = 20001 (*) Correct. See Section 17 28. 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 Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 29. You want to retrieve a list of customers whose last names begin with the letters Fr . Which symbol should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points % (*) ~ # * Correct. See Section 17 30. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND..

Page 161: Final Exam Oracle

Correct. Section 17 31. When using the LIKE condition to search for _ symbols, which character can you use as the default ESCAPE option? Mark for Review (1) Points % ^ & \ (*) Correct. 32. 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 SELECT clause? Mark for Review (1) Points ONLY UNIQUE DISTINCT (*) DISTINCTROW Correct. See Section 17 33. Which comparison condition would you use to select rows that match a character pattern? Mark for Review (1) Points IN LIKE (*) ALMOST SIMILAR Correct. 34. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES table and display the columns as a combined character string. Which operator should you use? Markfor Review (1) Points +

Page 162: Final Exam Oracle

| || (*) AND Correct. See Section 17 35. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. 36. You need to display employees with salaries that are at least 30000 or higher. Which comparison operator should you use? Mark for Review (1) Points > "=>" >= (*) != Correct. Section 18 37. 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

Page 163: Final Exam Oracle

50 25 (*) 10 250 (*) 100 Correct. 38. 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 from left to right The OR and AND conditions have the same precedence and will be evaluated from right to left Correct. 39. 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 statement? Mark for Review (1) Points IN (*) AND LIKE BETWEEN ... AND ...

Page 164: Final Exam Oracle

Correct. 40. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200);

Mark for Review (1) Points 19 No rows will be returned 100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*) 200, 201, 202, 203, 204, 205, 206 Correct. 41. Evaluate this SELECT statement: SELECT employee_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Which clause contains an error? Mark for Review (1) Points SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3; Correct. 42. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*)

Page 165: Final Exam Oracle

The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 43. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Incorrect. See Section 18 44. Which clause would you include in a SELECT statement to sort the rows returned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct. 45. 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. 46. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last.

Page 166: Final Exam Oracle

The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct. 47. 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 include in the ORDER BY clause? Mark for Review (1) Points DESC (*) ASC SORT CHANGE Correct. 48. Which logical operator returns TRUE if either condition is true? Mark for Review (1) Points OR (*) AND NOT BOTH Correct. 49. 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_nameFROM employees ORDER BY DEPT;

Page 167: Final Exam Oracle

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. 50. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct.

Section 12 1. It is possible to implement non-transferability via a simple Foreign Key Relationship. True or False? Mark for Review (1) Points True False (*) Correct 2. What do you create when you transform a many to many relationship from your ER diagram into a physical design? Mark for Review (1) Points Unique key constraints

Page 168: Final Exam Oracle

Intersection entity Intersection table (*) Two tables with Foreign key constraints between them Correct 3. When translating an arc relationship to a physical design, you must turn the arc relationships into foreign keys. Assuming you are implementing an Exclusive Design, you must also create two Unique Key Constraints to ensure the Arc is implemented correctly. True or False? Mark for Review (1) Points True False (*) Correct 4. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level are implemented as foreign keys, but the foreign key columns allbecome mandatory. True or False? Mark for Review (1) Points True False (*) Correct 5. The transformation from an ER diagram to a physical design involves changing terminology. Primary Unique Identifiers in the ER diagram become __________ and relationships become ____________. Mark for Review (1) Points Foreign keys, Primary keys Primary keys, Foreign keys (*) Foreign keys, mandatory business rules Unique Keys, Primary keys Correct 6. Attributes become tables in a database. True or False? Mark for Review (1) Points True

Page 169: Final Exam Oracle

False (*) Correct 7. Why would this table name NOT work in an Oracle database? this_year_end+next_year Mark for Review (1) Points Table names must begin with an alphabetic character Too long The Plus sign + is not allowed in object names (*) None of the above Correct 8. Identify all of the incorrect statements that complete this sentence: A primary 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 table A set of columns in one table that uniquely identifies each row in another table (*) Only one column that must be null (*) Incorrect. Refer to Section 12 9. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*) False Correct 10. Foreign keys must be null. True or False? Mark for Review (1) Points True

Page 170: Final Exam Oracle

False (*) Correct Section 12 11. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Correct Section 13 12. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*) EVERY Correct. 13. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. Section 16 14. In the default order of precedence, which operator would be evaluated first? Mark for

Page 171: Final Exam Oracle

Review (1) Points Subtractions Multiplications (*) Additions Divisions Correct. 15. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection Correct. 16. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct. 17. Evaluate this SELECT statement: SELECT (salary * raise_percent) raise FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return? Mark for Review (1) Points Only zeroes Only null values (*)

Page 172: Final Exam Oracle

A null value or a zero depending on the value of the SALARY column A null value or a numeric value depending on the value of the SALARY column Correct. 18. Which SQL statement will return an error? Mark for Review (1) Points SEL * FR sky; (*) select star from sky; SELECT star FROM sky; SELECT * FROM sky; Correct. 19. You query the database with this SQL statement: SELECT * FROM transaction WHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*) Projection only Selection and projection only Projection, selection and joining Correct. 20. If a SQL statement returns data from two or more tables, which SQL capability is being used? Mark for Review (1) Points Selection Projection Joining (*) Insertion Correct.

Page 173: Final Exam Oracle

Section 16 21. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct 22. Would it be a good idea to model age as an attribute of STUDENT? Mark for Review (1) Points Yes Maybe it could stop us having to calculate someone's age every time we need it Sometimes No - it breaks the Normalization rules (*) Correct Section 17 23. Which operator is used to combine columns of character strings to other columns? Mark for Review (1) Points * / + || (*) Correct. See Section 17 24. Which symbol represents the not equal to condition? Mark for Review (1) Points # '+'

Page 174: Final Exam Oracle

!= (*) ~ Correct. 25. 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 SELECT clause? Mark for Review (1) Points ONLY UNIQUE DISTINCT (*) DISTINCTROW Correct. See Section 17 26. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? Mark for Review (1) Points IN LIKE BETWEEN...AND... (*) IS NULL Correct. 27. The Concatenation Operator does which of the following? Mark for Review (1) Points Links rows of data together inside the database. Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Correct. See Section 17 28. What does the DISTINCT keyword do when it is used in a SELECT clause? Mark for Review(1) Points

Page 175: Final Exam Oracle

Hides NULL values Eliminates all unique values and compares values Eliminates duplicate rows in the result (*) Eliminates only unique rows in the result Correct. See Section 17 29. Which of the following commands will display the last name concatenated with the job ID from the employees table, separated by a comma and space, and label the resulting column "Employee and Title"? Mark for Review (1) Points SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees; SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*) SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp; SELECT last_name||","|| job_id "Employee and Title" FROM employees; Correct. See Section 17 30. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND.. Correct. Section 17 31. Which SELECT statement will display both unique and non-unique combinations of the MANAGER_ID and DEPARTMENT_ID values from the EMPLOYEES table? Mark for 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;

Page 176: Final Exam Oracle

Correct. 32. You want to retrieve a list of customers whose last names begin with the letters Fr . Which symbol should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points % (*) ~ # * Correct. See Section 17 33. You need to display all the employees whose last name starts with the letters 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. See Section 17 34. The PRODUCT table contains these columns: PRODUCT_ID NUMBER(9) DESCRIPTION VARCHAR2(20) COST NUMBER(5,2) LOCATION_ID VARCHAR2(10)

You want to display product costs with these desired results: 1. The cost displayed for each product is increased by 10 percent. 2. The product location id must be 4859, 9789, or 9898. 3. Ten percent of the original cost is less than $10. Which statement should you issue? Mark for Review (1) Points SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 < 10.00 AND location_id IN (4859, 9789, 9898); (*) SELECT product_id, cost * .10 FROM product

Page 177: Final Exam Oracle

WHERE cost * 1.10 > 10.00 AND location_id IN (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * 1.10 < 10.00 AND location_id = (4859, 9789, 9898); SELECT product_id, cost * 1.10 FROM product WHERE cost * .10 > 10.00 AND location_id = (4859, 9789, 9898); Correct. See Section 17 35. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(9) PrimaryKey LAST_NAME VARCHAR2 (20) FIRST_NAME VARCHAR2 (20) DEPARTMENT_ID NUMBER(5) NOT NULL MANAGER_ID NUMBER(9) NOT NULL

Evaluate these two SELECT statements: 1. SELECT DISTINCT employee_id, department_id, manager_id FROM employees; 2. SELECT employee_id, department_id, manager_id FROM employees;

Which of the following statements is true? Mark for Review (1) Points The two statements will display the same data. (*) The first statement will display a particular DEPARTMENT_ID only once. The first statement will NOT display values from all of the rows in the EMPLOYEES table The second statement could display a unique combination of the EMPLOYEE_ID, MANAGER_ID, and DEPARTMENT_ID values more than once. Incorrect. See Section 17 36. You want to create a report that displays all employees who were hired before January 1, 2000 and whose annual salaries are greater than 50000. The EMPLOYEES table contains these columns:

EMPLOYEE_ID VARCHAR2(5) PRIMARY KEY LAST_NAME VARCHAR2(35) HIREDATE DATE DEPARTMENT_ID NUMBER(4)

The SALARY table contains these columns:

Page 178: Final Exam Oracle

SALARYID VARCHAR2(5) PRIMARY KEY SALARY NUMBER(5, 2) EMPLOYEE_ID VARCHAR2(5) FOREIGN KEY

Which query should you issue? Mark for Review (1) Points SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary USING employee_id WHERE hiredate < 01-jan-00 AND salary > 50000; SELECT last_name, hiredate, salary FROM employees JOIN salary ON employee_id = employee_id WHERE hiredate < '01-jan-00' AND salary > 50000; SELECT last_name, hiredate, salary FROM employees NATURAL JOIN salary WHERE hiredate < '01-jan-00' AND salary > 50000; (*) SELECT last_name, hiredate, salary FROM employees (+) salary WHERE hiredate < '01-jan-00' AND salary > 50000; Correct Section 18 37. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct. 38. 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 include in the ORDER BY clause? Mark for Review (1) Points DESC (*)

Page 179: Final Exam Oracle

ASC SORT CHANGE Correct. 39. Which clause would you include in a SELECT statement to sort the rows returned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct. 40. Which of the following is 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. Section 18 41. The ORDER BY clause always comes last. True or False? Mark for Review (1) Points True (*) False Correct. 42. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values.

Page 180: Final Exam Oracle

To test for values in a list. Match a character pattern. (*) To find Null values. Correct. 43. 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. 44. Evaluate this SELECT statement: SELECT last_name, first_name, email FROM employees ORDER BY email;

If the EMAIL column contains null values, which statement is true? Mark for Review (1) Points Null email values will be displayed first in the result. Null email values will be displayed last in the result. (*) Null email values will not be displayed in the result. The result will not be sorted. Correct. 45. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true?

Page 181: Final Exam Oracle

Mark for Review (1) Points The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 46. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. 47. 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 from left to right The OR and AND conditions have the same precedence and will be evaluated from right to left Correct.

Page 182: Final Exam Oracle

48. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_id FROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 49. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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;

Page 183: Final Exam Oracle

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. 50. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct. Section 11 1. Entity integrity refers to Mark for Review (1) Points Tables always containing text data Tables always containing numeric data Columns having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. Tables having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. (*) Incorrect. Refer to Section 11 Lesson 1. 2. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*)

Page 184: Final Exam Oracle

False Correct 3. Foreign keys must be null. True or False? Mark for Review (1) Points True False (*) Correct 4. Identify all of the incorrect statements that complete this sentence: A primary 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 table A set of columns in one table that uniquely identifies each row in another table (*) Only one column that must be null (*) Incorrect. Refer to Section 11 Lesson 1. 5. If a primary key is a set of columns then one column must be null. True or False? Mark for Review (1) Points True False (*) Correct 6. 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

Page 185: Final Exam Oracle

Correct 7. Attributes become tables in a database. True or False? Mark for Review (1) Points True False (*) Correct 8. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key Constraint Column (*) Correct 9. One-to-One relationships are transformed into Check Constraints in the tables created at either end of that relationship. True or False? Mark for Review (1) Points True False (*) Correct 10. What do you create when you transform a many to many relationship from your ER diagram into a physical design? Mark for Review (1) Points Unique key constraints Intersection entity Intersection table (*) Two tables with Foreign key constraints between them Correct Section 11 11. Which of the following are reasons why you should consider using a Subtype

Page 186: Final Exam Oracle

Implementation? Mark for Review (1) Points The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*) Most of the relationships are at the supertype level Correct Section 12 12. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. 13. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True False (*) Correct. 14. 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 (*)

Page 187: Final Exam Oracle

Correct. 15. The f_customers table contains the following data: ID Name Address City State Zip 1 Cole Bee 123 Main Street Orlando FL 32838 2 Zoe Twee 1009 Oliver Avenue Boston MA 02116 3 Sandra Lee 22 Main Street Tampa FL 32444

If you run the following statement: DELETE FROM F_CUSTOMERS WHERE ID <= 2;

How many rows will be left in the table? Mark for Review (1) Points 0 3 1 (*) 2 Correct. 16. Once you have created a table, it is not possible to alter the definition of it. If you need toadd 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. Section 13 17. System Documentation is developed right at the end once the system has gone live and users have been using it for a little while. You are more likely to get it correct that way. True or False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 13 Lesson 1.

Page 188: Final Exam Oracle

18. Systems are always just rolled out as soon as the programming phase is finished. No further work is required once the development is finished. True or False? Mark for Review (1) Points True False (*) Correct. Section 15 19. You query the database with this SQL statement: SELECT * FROM transactionWHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*) Projection only Selection and projection only Projection, selection and joining Incorrect. See Section 15 Lesson 1. 20. You query the database with this SQL statement: SELECT * FROM students; Why would you use this statement? Mark for Review (1) Points To insert data To view data (*) To display the table structure To delete data Correct. Section 15 21. The EMPLOYEES table contains these columns: SALARY NUMBER(7,2) BONUS NUMBER(7,2)

Page 189: Final Exam Oracle

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. 22. In which clause of a SELECT statement would you specify the name of the table 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 SELECT statement. Correct. 23. You want to create a list of all albums that have been produced by the company. The list should include the title of the album, the artist's name, and the date the album was released. The ALBUMS table includes the following columns: ALB_TITLE VARCHAR2(150) NOT NULL ALB_ARTIST VARCHAR2(150) NOT NULL ALB_DATE DATE NOT NULL

Which statement can you use to retrieve the necessary information? Mark for Review (1) Points

Page 190: Final Exam Oracle

SELECT * FROM albums; (*) SELECT alb_title, alb_artist, alb_dates FROM album; SELECT alb_title, alb_artist, alb_dates FROM albums; SELECT alb_title; alb_artist; alb_date FROM albums; Correct. 24. When listing columns in the SELECT list, what should you use to separate the columns? Mark for Review (1) Points Commas (*) Semicolons Dashes Underscores Correct. Section 16 25. You need to display employees whose salary is in the range of 10000 through 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

Page 191: Final Exam Oracle

AND salary BETWEEN 25000 AND 10000 (*) Correct. 26. You need to display employees with salaries that are at least 30000 or higher. Which comparison operator should you use? Mark for Review (1) Points > "=>" >= (*) != Correct. 27. When using the LIKE condition, which symbol represents any sequence of none, one or more characters? Mark for Review (1) Points _ % (*) # & Correct. 28. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct. 29. Which statement best describes how column headings are displayed by default in Oracle Application Express: Mark for Review (1) Points Column headings are displayed left-justified and in lowercase.

Page 192: Final Exam Oracle

Column headings are displayed left-justified and in uppercase. Column headings are displayed centered and in uppercase. (*) Column headings are displayed centered and in mixed case. Correct. 30. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES table and display the columns as a combined character string. Which operator should you use? Markfor Review (1) Points + | || (*) AND Correct. Section 16 31. Which SELECT statement will display both unique and non-unique combinations of the MANAGER_ID and DEPARTMENT_ID values from the EMPLOYEES table? Mark for 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. 32. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the DEPARTMENT_ID column to this specific list of values? Mark for Review (1) Points = != IN (*) BETWEEN..AND..

Page 193: Final Exam Oracle

Correct. 33. You need to display all the employees whose last name starts with the letters 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. 34. Which of the following commands will display the last name concatenated with the job ID from the employees table, separated by a comma and space, and label the resulting column "Employee and Title"? Mark for Review (1) Points SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees; SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*) SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp; SELECT last_name||","|| job_id "Employee and Title" FROM employees; Correct. 35. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Correct 36. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above.

Page 194: Final Exam Oracle

Correct Section 17 37. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Correct. 38. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Correct. 39. Which statement about the default sort order is true? Mark for Review (1) Points The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct. 40. Which comparison condition means "Less Than or Equal To"? Mark for Review (1) Points "=)" "+<"

Page 195: Final Exam Oracle

">=" "<=" (*) Section 17 41. 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. 42. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 43. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_idFROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct.

Page 196: Final Exam Oracle

44. Evaluate this SELECT statement: SELECT employee_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Which clause contains an error? Mark for Review (1) Points SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3; Incorrect! See Section 17 Lesson 2. 45. 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 statement? Mark for Review (1) Points IN (*) AND LIKE BETWEEN ... AND ... Correct. 46. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values.

Page 197: Final Exam Oracle

The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 47. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. 48. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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;(*)

Page 198: Final Exam Oracle

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. 49. 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_nameFROM 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. 50. 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)

Page 199: Final Exam Oracle

You want to display all players' names with position 6900 or greater. You want the players names to be displayed alphabetically by last name and then by first name. 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; 1. 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 or False? Mark for Review (1) Points True False (*) Correct 2. Foreign keys must be null. True or False? Mark for Review (1) Points True False (*) Correct 3. Identify all of the incorrect statements that complete this sentence: A primary key is:

Page 200: Final Exam Oracle

(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 table A set of columns in one table that uniquely identifies each row in another table (*) Only one column that must be null (*) Incorrect. Refer to Section 11 Lesson 1. 4. The text below is an example of what constraint type:The value in the manager_id column of the EMPLOYEES table must match a value in the employee_id column in the EMPLOYEES table. Mark for Review (1) Points Entity integrity User-defined integrity Column integrity Referential integrity (*) Correct 5. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Correct 6. 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

Page 201: Final Exam Oracle

7. 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 (*) Correct 8. In a physical data model, an attribute becomes a _____________. Mark for Review (1) Points Table Foreign Key Constraint Column (*) Correct 9. It is possible to implement non-transferability via a simple Foreign Key Relationship. True or False? Mark for Review (1) Points True False (*) Correct 10. The Oracle Database can implement a many to many relationship. You simply create two foreign keys between the two tables. True or False? Mark for Review (1) Points True False (*) Correct

Section 11

Page 202: Final Exam Oracle

11. Which of the following are reasons why you should consider using a Subtype Implementation? Mark for Review (1) Points The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*) Most of the relationships are at the supertype level Correct Section 12 12. The DESCRIBE command returns all rows from a table. True or False? Mark for Review (1) Points True False (*) Correct. 13. 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. 14. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review (1) Points ANYWHERE WHICH WHERE (*)

Page 203: Final Exam Oracle

EVERY Correct. 15. The f_customers table contains the following data: ID Name Address City State Zip 1 Cole Bee 123 Main Street Orlando FL 32838 2 Zoe Twee 1009 Oliver Avenue Boston MA 02116 3 Sandra Lee 22 Main Street Tampa FL 32444

If you run the following statement: DELETE FROM F_CUSTOMERS WHERE ID <= 2;

How many rows will be left in the table? Mark for Review (1) Points 0 3 1 (*) 2 Correct. 16. Once you have created a table, it is not possible to alter the definition of it. If you need toadd 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. Section 13 17. Systems are always just rolled out as soon as the programming phase is finished. No further work is required once the development is finished. True or False? Mark for Review (1) Points True False (*) Correct.

Page 204: Final Exam Oracle

18. System Documentation is developed right at the end once the system has gone live and users have been using it for a little while. You are more likely to get it correct that way. True or False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 13 Lesson 1. Section 15 19. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions and Addition are at the same level and would be evaluated first based on left toright order Multiplications and Division are at the same level and would be evaluated first based on left to right order (*) Additions and Multiplications are at the same level and would be evaluated first based on left to right order Divisions and Subtractions are at the same level and would be evaluated first based on left to right order Incorrect. See Section 15 Lesson 1. 20. When listing columns in the SELECT list, what should you use to separate the columns? Mark for Review (1) Points Commas (*) Semicolons Dashes Underscores

21. The EMPLOYEES table contains these columns: SALARY NUMBER(7,2) BONUS NUMBER(7,2)

Page 205: Final Exam Oracle

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. 22. In which clause of a SELECT statement would you specify the name of the table 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 SELECT statement. Correct. 23. You query the database with this SQL statement: SELECT * FROM students; Why would you use this statement? Mark for Review (1) Points To insert data To view data (*)

Page 206: Final Exam Oracle

To display the table structure To delete data Correct. 24. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the following EXCEPT: Mark for Review (1) Points Projection Manipulation (*) Joining Selection Correct. Section 16 25. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? Mark for Review (1) Points IN LIKE BETWEEN...AND... (*) IS NULL Correct. 26. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct.

Page 207: Final Exam Oracle

27. You need to display employees with salaries that are at least 30000 or higher. Which comparison operator should you use? Mark for Review (1) Points > "=>" >= (*) != Correct. 28. The Concatenation Operator does which of the following? Mark for Review (1) Points Links rows of data together inside the database. Links two or more columns or literals to form a single output column (*) Is represented by the asterisk (*) symbol Separates columns. Correct. 29. Which symbol represents the not equal to condition? Mark for Review (1) Points # +' != (*) ~ Correct. 30. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct.

Page 208: Final Exam Oracle

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Exam covers Sections 11-17 of Database Design.

Section 16 31. You need to display all the values in the EMAIL column that contains the underscore (_) character as part of that email address. The WHERE clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator? Mark for Review (1) Points The ESCAPE option (\) and one or more percent signs (%) The (+) operator A percent sign (%) The ESCAPE option (\) (*) Correct. 32. Evaluate this SELECT statement: SELECT * FROM employeesWHERE department_id IN(10, 20, 30) AND salary > 20000;

Which values would cause the logical condition to return TRUE? Mark for Review (1) Points DEPARTMENT_ID = 10 and SALARY = 20000 DEPARTMENT_ID = 20 and SALARY = 20000 DEPARTMENT_ID = null and SALARY = 20001 DEPARTMENT_ID = 10 and SALARY = 20001 (*) Correct. 33. 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 Oracle Application Express? Mark for Review (1) Points

Page 209: Final Exam Oracle

The heading will display with the first character capitalized and centered. The heading will display with the first character capitalized and left justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 34. You want to retrieve a list of customers whose last names begin with the letters Fr . Which keyword should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points AND IN BETWEEN LIKE (*) Correct. 35. Would it be a good idea to model age as an attribute of STUDENT? Mark for Review (1) Points Yes Maybe it could stop us having to calculate someone's age every time we need it Sometimes No - it breaks the Normalization rules (*) Correct 36. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Correct

Page 210: Final Exam Oracle

Section 17 37. Which comparison condition means "Less Than or Equal To"? Mark for Review (1) Points "=)" "+<" ">=" "<=" (*) Correct. 38. Which logical operator returns TRUE if either condition is true? Mark for Review (1) Points OR (*) AND NOT BOTH Incorrect. See Section 17 Lesson 1. 39. Which clause would you include in a SELECT statement to sort the rows returned by the LAST_NAME column? Mark for Review (1) Points ORDER BY (*) WHERE FROM HAVING Correct. 40. 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.

Page 211: Final Exam Oracle

The order of operator precedence is NOT, OR, and AND. The order of operator precedence is NOT, AND, and OR. (*) Correct.

Page 4 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Exam covers Sections 11-17 of Database Design.

Section 17 41. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct. 42. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values. To test for values in a list. Match a character pattern. (*) To find Null values. Correct. 43. You attempt to query the database with this SQL statement: SELECT product_id "Product Number", category_id "Category", price "Price"

Page 212: Final Exam Oracle

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. 44. Evaluate this SQL statement: SELECT product_id, product_name, price FROM products ORDER BY product_name, price;

What occurs when the statement is executed? Mark for Review (1) Points The results are sorted numerically only. The results are sorted alphabetically only. The results are sorted numerically and then alphabetically. The results are sorted alphabetically and then numerically. (*) Correct. 45. Evaluate this SELECT statement: SELECT last_name, first_name, email FROM employees ORDER BY email;

If the EMAIL column contains null values, which statement is true? Mark for Review (1) Points Null email values will be displayed first in the result. Null email values will be displayed last in the result. (*) Null email values will not be displayed in the result. The result will not be sorted.

Page 213: Final Exam Oracle

Correct. 46. Evaluate this SELECT statement: SELECT last_name, first_name, department_id, manager_idFROM employees;

You need to sort data by manager id values and then alphabetically by employee last name and first name values. Which ORDER BY clause could you use? Mark for Review (1) Points ORDER BY department_id, last_name ORDER BY manager_id, last_name, first_name (*) ORDER BY last_name, first_name, manager_id ORDER BY manager_id, first_name, last_name Correct. 47. 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. 48. 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)

Page 214: Final Exam Oracle

You want to display all players' names with position 6900 or greater. You want the players names to be displayed alphabetically by last name and then by first name. 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. 49. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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

Page 215: Final Exam Oracle

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. 50. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct.

Page 5 of 5

Test: Final Exam Semester 1

Page 216: Final Exam Oracle

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Semester 1 Final Exam covers Sections 11-17 of Database Design.

Section 11 1. If a primary key is a set of columns then one column must be null. True or False? Mark for Review (1) Points True False (*) Correct 2. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 3. 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 or False? Mark for Review (1) Points True False (*) Correct 4. Entity integrity refers to Mark for Review (1) Points Tables always containing text data Tables always containing numeric data Columns having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database.

Page 217: Final Exam Oracle

Tables having Primary Keys, Foreign Keys, Unique Keys and Check constraints defined in the database. (*) Correct 5. The explanation below is a column integrity constraint:A column must contain only values consistent with the defined data format of the column. True or False? Mark for Review (1) Points True (*) False Correct 6. Attributes become tables in a database. True or False? Mark for Review (1) Points True False (*) Correct 7. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique Identifiers become Mark for Review (1) Points Columns Tables Unique Constraints (*) Primary Key Constraints Correct 8. The transformation from an ER diagram to a physical design involves changing terminology. Primary Unique Identifiers in the ER diagram become __________ and relationships become ____________. Mark for Review (1) Points Foreign keys, Primary keys Primary keys, Foreign keys (*) Foreign keys, mandatory business rules

Page 218: Final Exam Oracle

Unique Keys, Primary keys Correct 9. Many to many relationships are implemented via a structure called a: ________________ Mark for Review (1) Points Supertype Intersection Table (*) Intersection Entity Subtype Correct 10. It is possible to implement non-transferability via a simple Foreign Key Relationship. True or False? Mark for Review (1) Points True False (*) Correct

Section 11 11. Which of the following are reasons why you should consider using a Subtype Implementation? Mark for Review (1) Points The resulting table will reside in a single database and be used by just ONE user. When the common access paths for the supertypes are different. Business functionality and business rules, access paths and frequency of access are all very different between subtypes. (*) Most of the relationships are at the supertype level Correct Section 12 12. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review

Page 219: Final Exam Oracle

(1) Points ANYWHERE WHICH WHERE (*) EVERY Correct. 13. 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. 14. What command will return data from the database to you? Mark for Review (1) Points FETCH GET SELECT (*) RETURN Correct. 15. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid statement. True or False? Mark for Review (1) Points True False (*) Correct. 16. The f_customers table contains the following data: ID Name Address City State Zip

Page 220: Final Exam Oracle

1 Cole Bee 123 Main Street Orlando FL 32838 2 Zoe Twee 1009 Oliver Avenue Boston MA 02116 3 Sandra Lee 22 Main Street Tampa FL 32444

If you run the following statement: DELETE FROM F_CUSTOMERS WHERE ID <= 2;

How many rows will be left in the table? Mark for Review (1) Points 0 3 1 (*) 2 Correct. Section 13 17. System Documentation is developed right at the end once the system has gone live and users have been using it for a little while. You are more likely to get it correct that way. True or False? Mark for Review (1) Points True False (*) Correct. 18. Systems are always just rolled out as soon as the programming phase is finished. No further work is required once the development is finished. True or False? Mark for Review (1) Points True False (*) Correct. Section 15 19. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review (1) Points

Page 221: Final Exam Oracle

6 8 (*) 10 13 Correct. 20. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review (1) Points Joining only Selection only Projection only (*) Projection and Selection Correct.

Section 15 21. In a SQL statement, which clause specifies one or more columns to be returned 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 SELECT statement. Correct. 22. You query the database with this SQL statement: SELECT * FROM transactionWHERE product_id = 4569;

Which SQL SELECT statement capabilities are achieved when this statement is executed? Mark for Review (1) Points Selection only (*)

Page 222: Final Exam Oracle

Projection only Selection and projection only Projection, selection and joining Correct. 23. In the default order of precedence, which operator would be evaluated first? Mark for Review (1) Points Subtractions and Addition are at the same level and would be evaluated first based on left toright order Multiplications and Division are at the same level and would be evaluated first based on left to right order (*) Additions and Multiplications are at the same level and would be evaluated first based on left to right order Divisions and Subtractions are at the same level and would be evaluated first based on left to right order Correct. 24. 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.

Page 223: Final Exam Oracle

One of the statements will NOT execute. Incorrect. See Section 15 Lesson 1. Section 16 25. Where in a SQL statement can you not use arithmetic operators? Mark for Review (1) Points SELECT FROM (*) WHERE NONE Correct. 26. 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 SELECT clause? Mark for Review (1) Points ONLY UNIQUEONE DISTINCT (*) DISTINCTROW Correct. 27. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator should you use? Mark for Review (1) Points IN LIKE BETWEEN...AND... (*) IS NULL Correct.

Page 224: Final Exam Oracle

28. Which symbol represents the not equal to condition? Mark for Review (1) Points # +' != (*) ~ Correct. 29. Which comparison operator searches for a specified character pattern? Mark for Review (1) Points IN LIKE (*) BETWEEN...AND... IS NULL Correct. 30. When using the LIKE condition, which symbol represents any sequence of none, one or more characters? Mark for Review (1) Points _ % (*) # & Correct.

Section 16 31. You want to retrieve a list of customers whose last names begin with the letters Fr . Which keyword should you include in the WHERE clause of your SELECT statement to achieve the desired result? Mark for Review (1) Points AND IN BETWEEN

Page 225: Final Exam Oracle

LIKE (*) Correct. 32. 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 Oracle 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 justified. The heading will display as uppercase and centered. (*) The heading will display as uppercase and left justified. Correct. 33. You want to determine the orders that have been placed by customers who reside in Chicago. You write this partial SELECT statement: SELECT orderid, orderdate, total FROM orders;

What should you include in your SELECT statement to achieve the desired results? Mark for Review (1) Points AND city = Chicago; AND city = 'Chicago'; WHERE city = 'Chicago'; (*) WHERE city = Chicago; Correct. 34. Which of the following commands will display the last name concatenated with the job ID from the employees table, separated by a comma and space, and label the resulting column "Employee and Title"? Mark for Review (1) Points SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees; SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*) SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp;

Page 226: Final Exam Oracle

SELECT last_name||","|| job_id "Employee and Title" FROM employees; Correct. 35. When is an entity in 2nd Normal Form? Mark for Review (1) Points When all non-UID attributes are dependent upon the entire UID. (*) When no attritibutes are mutually independant and fully independent on the primary key. When no attritibutes are mutually independent and all are fully dependent on the primary key. None of the Above. Incorrect. Refer to Section 6 Lesson 3. 36. Any Non-UID must be dependant on the entire UID. True or False? Mark for Review (1) Points True (*) False Correct Section 17 37. 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. 38. Which of the following best describes the meaning of the LIKE operator? Mark for Review(1) Points Display rows based on a range of values. To test for values in a list.

Page 227: Final Exam Oracle

Match a character pattern. (*) To find Null values. Correct. 39. 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. 40. From left to right, what is the correct order of Precedence? Mark for Review (1) Points Arithmetic, Concatenation, Comparison, OR (*) NOT, AND, OR, Arithmetic Arithmetic, NOT, Logical, Comparison Arithmetic, NOT, Concatenation, Logical Correct.

Section 17 41. Which statement about the ORDER BY clause is true? Mark for Review (1) Points You can use a column alias in the ORDER BY clause. (*) The default sort order of the ORDER BY clause is descending. The ORDER BY clause can only contain columns that are included in the SELECT list. The ORDER BY clause should immediately precede the FROM clause in a SELECT statement Correct. 42. Which statement about the default sort order is true? Mark for Review (1) Points

Page 228: Final Exam Oracle

The lowest numeric values are displayed last. The earliest date values are displayed first. (*) Null values are displayed first. Character values are displayed in reverse alphabetical order. Correct. 43. Evaluate this SELECT statement: SELECT first_name, last_name, email FROM employees ORDER BY last_name;

Which statement is true? Mark for Review (1) Points The rows will not be sorted. The rows will be sorted alphabetically by the LAST_NAME values. (*) The rows will be sorted in reverse alphabetical order by the LAST_NAME values. The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values Correct. 44. 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.

Page 229: Final Exam Oracle

45. Evaluate this SELECT statement: SELECT employee_id, last_name, first_name, salary 'Yearly Salary' FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3;

Which clause contains an error? Mark for Review (1) Points SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*) FROM employees WHERE salary IS NOT NULL ORDER BY last_name, 3; Correct. 46. You need to create a report to display all employees that were hired on or 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 employeesWHERE 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"

Page 230: Final Exam Oracle

FROM employeesWHERE hire_date <= '01-JAN-96'; (*) Correct. 47. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees;

How will the results of this query be sorted? Mark for Review (1) Points The database will display the rows in whatever order it finds it in the database, so no particular order. (*) The results will be sorted ascending by the LAST_NAME column only. The results will be sorted ascending by LAST_NAME and FIRST_NAME only. The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. Correct. 48. Evaluate this SQL statement: SELECT e.employee_id, e.last_name, e.first_name, m.manager_id FROM employees e, employees m ORDER BY e.last_name, e.first_name WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem? Mark for Review (1) Points Reorder the clauses in the query. (*) Remove the table aliases in the WHERE clause. Remove the table aliases in the ORDER BY clause. Include a HAVING clause. Correct. 49. 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:

Page 231: Final Exam Oracle

1. SELECT DISTINCT department_id DEPT, last_name, first_name FROM employees ORDER BY department_id;

2. SELECT department_id DEPT, last_name, first_nameFROM 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. 50. 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 is in the range from 25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which statement should you 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

Page 232: Final Exam Oracle

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.