Vous êtes sur la page 1sur 19

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 16
(Answer all questions in this section)
1. 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.
2. Which comparison condition would you use to select rows that match a chara
cter pattern? Mark for Review
(1) Points
IN
LIKE (*)
ALMOST
SIMILAR
Correct.
3. When using the LIKE condition, which symbol represents any sequence of non
e, one or more characters? Mark for Review
(1) Points

_
% (*)
#
&
Correct.
4. 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.
5. 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 SELEC
T clause? Mark for Review
(1) Points
ONLY
UNIQUEONE
DISTINCT (*)
DISTINCTROW
Correct.
6. You need to display employees whose salary is in the range of 10000 throug
h 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.
7. Which operator is used to combine columns of character strings to other co
lumns? Mark for Review
(1) Points
*
/
+
|| (*)
Correct.
8. You need to display employees whose salary is in the range of 30000 and 50
000. Which comparison operator should you use? Mark for Review
(1) Points
IN
LIKE
BETWEEN...AND... (*)
IS NULL
Correct.
9. You want to determine the orders that have been placed by customers who re
side 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.
10. 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.

Page 1 of 5
********************************
Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 16
(Answer all questions in this section)
11. 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.
12. Evaluate this SELECT statement:
SELECT last_name, first_name, salary
FROM employees;
How will the heading for the SALARY column appear in the display by default in O

racle Application Express?


Mark for Review
(1) Points
The heading will display with the first character capitalized and centered.
The heading will display with the first character capitalized and left justi
fied.
The heading will display as uppercase and centered. (*)
The heading will display as uppercase and left justified.
Correct.
13. 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 emp
loyee 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;
SELECT last_name, employee_id
FROM employees
WHERE employee_id equals 176;

Incorrect. See Section 16 Lesson 2.

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

Correct.
18. You need to create a report to display all employees that were hired on o
r after January 1, 1996. The data should display in this format:
Employee Start Date and Salary
14837 - Smith 10-MAY-92 / 5000
Which SELECT statement could you use?
Mark for Review
(1) Points
SELECT employee_id || - || last_name "Employee",
hire_date || / || salary "Start Date and Salary
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||' '|| last_name "Employee",


hire_date ||' '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= 01-JAN-96';
SELECT employee_id ||'"- "|| last_name "Employee",
hire_date ||" / "|| salary Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';
SELECT employee_id ||' - '|| last_name 'Employee',
hire_date ||' / '|| salary 'Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';
SELECT employee_id ||' - '|| last_name "Employee",
hire_date ||' / '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';
(*)

Incorrect! See Section 17 Lesson 2.


19. 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 value
s.
The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_N
AME values
Correct.
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9) PK
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
Compare these two SQL statements:
1.

SELECT DISTINCT department_id DEPT, last_name, first_name


FROM employees
ORDER BY department_id;
2.
SELECT department_id DEPT, last_name, first_name
FROM employees
ORDER BY DEPT;
How will the results differ?
Mark for Review
(1) Points
One of the statements will return a syntax error.
One of the statements will eliminate all duplicate DEPARTMENT_ID values.
There is no difference in the result between the two statements. (*)
The statements will sort on different column values.
Correct.

Page 2 of 5
***************************************
Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 17
(Answer all questions in this section)
21. 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.
22. The PLAYERS table contains these columns:
PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You must display the player name, team id, and salary for players whose salary i
s in the range from 25000 through 100000 and whose team id is in the range of 12
00 through 1500. The results must be sorted by team id from lowest to highest an
d then further sorted by salary from highest to lowest. Which statement should y
ou use to display the desired result?
Mark for Review
(1) Points
SELECT last_name, first_name, team_id, salary
FROM players
WHERE (salary > 25000 OR salary < 100000)
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary;
SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 25000 AND 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary DESC;
(*)
SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary > 24999.99 AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;
SELECT last_name, first_name, team_id, salary
FROM players
WHERE salary BETWEEN 24999.99 AND 100000.01
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id DESC, salary DESC;

Correct.
23. Which logical operator returns TRUE if either condition is true? Mark fo
r Review
(1) Points
OR (*)

AND
NOT
BOTH
Correct.
24. 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.
25. The ORDER BY clause always comes last. True or False? Mark for Review
(1) Points
True (*)
False
Correct.
26. 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.
27. You need to change the default sort order of the ORDER BY clause so that
the data is displayed in reverse alphabetical order. Which keyword should you in
clude in the ORDER BY clause? Mark for Review
(1) Points
DESC (*)
ASC

SORT
CHANGE
Correct.
28. From left to right, what is the correct order of Precedence? Mark for Re
view
(1) Points
Arithmetic, Concatenation, Comparison, OR (*)
NOT, AND, OR, Arithmetic
Arithmetic, NOT, Logical, Comparison
Arithmetic, NOT, Concatenation, Logical
Correct.

Section 12
(Answer all questions in this section)
29. 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.
30. What command will return data from the database to you? Mark for Review
(1) Points
FETCH
GET
SELECT (*)
RETURN
Correct.

Page 3 of 5
***************************************
Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 12
(Answer all questions in this section)
31. 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.
32. Once you have created a table, it is not possible to alter the definition
of it. If you need to add a new column you must delete the table definition and
create a new, correct table. True or False? Mark for Review
(1) Points
True
False (*)
Correct.
33. 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.

Section 11
(Answer all questions in this section)
34. A table must have a primary key. True or False? Mark for Review
(1) Points
True
False (*)
Correct
35. The text below is an example of what constraint type:
If the number of BOOKS lent to a BORROWER in the LIBRARY exceeds 5, then we must
send him/her a letter requesting the return of the BOOKS, which will require ex
tra programming to enforce.
Mark for Review
(1) Points
Entity integrity
User-defined integrity (*)
Column integrity
Referential integrity
Correct
36. 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

37. A foreign key cannot refer to a primary key in the same table. True or Fa
lse? Mark for Review
(1) Points
True
False (*)
Correct
38. Foreign keys must be null. True or False? Mark for Review
(1) Points
True
False (*)
Correct
39. The transformation from an ER diagram to a physical design involves chang
ing terminology. Secondary Unique Identifiers become Mark for Review
(1) Points
Columns
Tables
Unique Constraints (*)
Primary Key Constraints
Correct
40. 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 4 of 5

**************************************
Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 11
(Answer all questions in this section)
41. Why would this table name NOT work in an Oracle database? this_year_end+n
ext_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
42. What do you create when you transform a many to many relationship from yo
ur 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
43. An "Arc Implementation" can be done just like any other Relationship - yo
u simply add the required Foreign Keys. True or False? Mark for Review
(1) Points
True
False (*)
Correct

Section 15
(Answer all questions in this section)
44. If a SQL statement returns data from two or more tables, which SQL capabi
lity is being used? Mark for Review
(1) Points
Selection
Projection
Joining (*)
Insertion
Incorrect. See Section 15 Lesson 1.
45. In a SQL statement, which clause specifies one or more columns to be retu
rned by the query? Mark for Review
(1) Points
SELECT (*)
FROM
WHERE
Any of the above options, you can list columns wherever you want to in a SEL
ECT statement.
Incorrect. See Section 15 Lesson 1.
46. What would you use in the SELECT clause to return all the columns in the
table? Mark for Review
(1) Points
An asterisk (*) (*)
A minus sign (-)
A plus sign (+)
The ALL keyword
Correct.
47. Evaluate this SELECT statement:
SELECT (salary * raise_percent) raise
FROM employees;
If the RAISE_PERCENT column only contains null values, what will the statement r
eturn?
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.
48. In the default order of precedence, which operator would be evaluated fir
st? Mark for Review
(1) Points
Subtractions and Addition are at the same level and would be evaluated first
based on left to right order
Multiplications and Division are at the same level and would be evaluated fi
rst based on left to right order (*)
Additions and Multiplications are at the same level and would be evaluated f
irst based on left to right order
Divisions and Subtractions are at the same level and would be evaluated firs
t based on left to right order
Correct.
49. 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.
50. 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 exec
uted?
Mark for Review
(1) Points

Selection only (*)


Projection only
Selection and projection only
Projection, selection and joining
Correct.

Page 5 of 5