You are on page 1of 19

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 12
(Answer all questions in this section)
1. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid st
atement. True or False? Mark for Review
(1) Points
True
False (*)
Correct.
2. 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.
3. What command can be used to create a new row in a table in the database?
Mark for Review
(1) Points
CREATE
NEW
ADD

INSERT (*)
Correct.
4. What command will return data from the database to you? Mark for Review
(1) Points
FETCH
GET
SELECT (*)
RETURN
Correct.
5. The DESCRIBE command returns all rows from a table. True or False? Mark f
or Review
(1) Points
True
False (*)
Correct.

Section 11
(Answer all questions in this section)
6. One-to-One relationships are transformed into Check Constraints in the tab
les created at either end of that relationship. True or False? Mark for Review
(1) Points
True
False (*)
Correct
7. The transformation from an ER diagram to a physical design involves changi
ng terminology. Secondary Unique Identifiers become Mark for Review
(1) Points
Columns
Tables
Unique Constraints (*)

Primary Key Constraints


Correct
8. In an Oracle database, why would 1_TABLE not work as a table name? Mark f
or 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
9. In a physical data model, an attribute becomes a _____________. Mark for
Review
(1) Points
Table
Foreign Key
Constraint
Column (*)
Correct
10. 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

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 11
(Answer all questions in this section)
11. 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
12. Identify all of the incorrect statements that complete this sentence: A p
rimary key is: (Choose three) Mark for Review
(1) Points
(Choose all correct answers)
A single column that uniquely identifies each column in a table (*)
One or more columns in a table that uniquely identifies each row in that tab
le
A set of columns in one table that uniquely identifies each row in another t
able (*)
Only one column that must be null (*)
Correct
13. 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
14. If a primary key is a set of columns then one column must be null. True o
r False? Mark for Review
(1) Points
True
False (*)
Correct
15. Foreign keys must be null. True or False? Mark for Review
(1) Points
True
False (*)
Correct

Section 15
(Answer all questions in this section)
16. 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.
17. In which clause of a SELECT statement would you specify the name of the t
able or tables being queried? Mark for Review

(1) Points
The FROM clause (*)
The SELECT clause
The WHERE clause
Any of the above options, you can list tables wherever you want to in a SELE
CT statement.
Correct.
18. If a SQL statement returns data from two or more tables, which SQL capabi
lity is being used? Mark for Review
(1) Points
Selection
Projection
Joining (*)
Insertion
Correct.
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.


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

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 15
(Answer all questions in this section)
21. 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.

22. In a SELECT clause, what is the result of 2 + 3 * 2? Mark for Review


(1) Points
6
8 (*)
10
13
Correct.

Section 17
(Answer all questions in this section)
23. 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.
24. 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 s
tatement
Correct.
25. Which comparison condition means "Less Than or Equal To"? Mark for Revie
w
(1) Points
"=)"

"+<"
">="
"<=" (*)
Incorrect. See Section 17 Lesson 1.
26. Which logical operator returns TRUE if either condition is true? Mark fo
r Review
(1) Points
OR (*)
AND
NOT
BOTH
Correct.
27. 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.
28. 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.
29. 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.
30. 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 data
base, 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.

Page 3 of 5

Test: Final Exam Semester 1

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 17
(Answer all questions in this section)

31. Evaluate this SELECT statement:


SELECT *
FROM employees
WHERE department_id = 34
OR department_id = 45
OR department_id = 67;
Which operator is the equivalent of the OR conditions used in this SELECT statem
ent?
Mark for Review
(1) Points
IN (*)
AND
LIKE
BETWEEN ... AND ...
Correct.
32. 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.
33. 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.
34. 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.
35. 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.
36. The PLAYERS table contains these columns:
PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You want to display all players' names with position 6900 or greater. You want t
he players names to be displayed alphabetically by last name and then by first n
ame. Which statement should you use to achieve the required results?
Mark for Review
(1) Points
SELECT last_name, first_name
FROM players
WHERE position_id >= 6900
ORDER BY last_name, first_name;
(*)
SELECT last_name, first_name
FROM players
WHERE position_id > 6900
ORDER BY last_name, first_name;
SELECT last_name, first_name
FROM players
WHERE position_id <= 6900
ORDER BY last_name, first_name;
SELECT last_name, first_name
FROM players

WHERE position_id >= 6900


ORDER BY last_name DESC, first_name;

Correct.
37. 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.

Section 16
(Answer all questions in this section)
38. Where in a SQL statement can you not use arithmetic operators? Mark for
Review
(1) Points
SELECT
FROM (*)
WHERE
NONE
Correct.

39. When using the LIKE condition, which symbol represents any sequence of no
ne, one or more characters? Mark for Review
(1) Points
_
% (*)
#
&
Correct.
40. Which operator is used to combine columns of character strings to other c
olumns? 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 (*) indica
tes a correct answer.
Semester 1 Final Exam covers Sections 11-17 of Database Design.
Section 16
(Answer all questions in this section)
41. When using the LIKE condition to search for _ symbols, which character ca
n you use as the default ESCAPE option? Mark for Review
(1) Points
%

^
&
\ (*)
Correct.
42. Which comparison condition would you use to select rows that match a char
acter pattern? Mark for Review
(1) Points
IN
LIKE (*)
ALMOST
SIMILAR
Correct.
43. Which symbol represents the not equal to condition? Mark for Review
(1) Points
#
+'
!= (*)
~
Correct.
44. You need to display only unique combinations of the LAST_NAME and MANAGER
_ID columns in the EMPLOYEES table. Which keyword should you include in the SELE
CT clause? Mark for Review
(1) Points
ONLY
UNIQUEONE
DISTINCT (*)
DISTINCTROW
Correct.
45. You need to display all the employees whose last name starts with the let

ters 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.
46. 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.
47. What will be the result of the SELECT statement and what will display?
SELECT last_name, salary, salary + 300
FROM employees;
Mark for Review
(1) Points
Display the last name, salary and the results of adding 300 to each salary f
or 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 th
e new salary.
Display the last name, salary and the results of adding 300 to the salary of
the first employee row
Correct.
48. 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.
49. Which SELECT statement will display both unique and non-unique combinatio
ns of the MANAGER_ID and DEPARTMENT_ID values from the EMPLOYEES table? Mark fo
r Review
(1) Points
SELECT manager_id, department_id DISTINCT FROM employees;
SELECT manager_id, department_id FROM employees; (*)
SELECT DISTINCT manager_id, department_id FROM employees;
SELECT manager_id, DISTINCT department_id FROM employees;
Correct.
50. You want to create a report that displays all employees who were hired be
fore 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;

Correct.

Page 5 of 5