You are on page 1of 13

Section 11

(Answer all questions in this section)


1. 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 (*)
2. A foreign key cannot refer to a primary key in the same table. True or False
? Mark for Review
(1) Points
True
False (*)
3. If a primary key is a set of columns then one column must be null. True or F
alse? Mark for Review
(1) Points

True
False (*)
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 o
r False?
Mark for Review
(1) Points
True
False (*)
5. A table must have a primary key. True or False? Mark for Review
(1) Points
True
False (*)
6. Foreign keys must be null. True or False? Mark for Review
(1) Points
True
False (*)
7. When mapping supertypes, relationships at the supertype level transform as u
sual. Relationships at subtype level are implemented as foreign keys, but the fo
reign key columns all become mandatory. True or False? Mark for Review
(1) Points
True
False (*)
8. In a physical data model, an attribute becomes a _____________. Mark for R
eview
(1) Points
Table
Foreign Key
Constraint
Column (*)
9. 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
10. Why would this table name NOT work in an Oracle database? this_year_end+ne
xt_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
11. 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
12. What command can be used to create a new row in a table in the database? M
ark for Review
(1) Points
CREATE
NEW
ADD
INSERT (*)
13. What command will return data from the database to you? Mark for Review
(1) Points
FETCH
GET
SELECT (*)
RETURN
14. 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
15. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid st
atement. True or False? Mark for Review
(1) Points
True
False (*)
16. You want to create a report that displays all employees who were hired befo
re 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;
17. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES t
able and display the columns as a combined character string. Which operator shou
ld you use? Mark for Review
(1) Points
+
|
|| (*)
AND
18. When using the LIKE condition to search for _ symbols, which character can
you use as the default ESCAPE option? Mark for Review
(1) Points
%
^
&
\ (*)
19. Which statement best describes how column headings are displayed by defaul
t 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
20. You need to display all the rows in the EMPLOYEES table that contain a null
value in the DEPARTMENT_ID column. Which comparison operator should you use? M
ark for Review
(1) Points
"= NULL"
NULL!
ISNULL
IS NULL (*)
21. When using the LIKE condition, which symbol represents any sequence of none
, one or more characters? Mark for Review
(1) Points
_
% (*)
#
&
22. You need to display employees whose salary is in the range of 30000 and 500
00. Which comparison operator should you use? Mark for Review
(1) Points
IN
LIKE
BETWEEN...AND... (*)

IS NULL
23. You need to display employees with salaries that are at least 30000 or high
er. Which comparison operator should you use? Mark for Review
(1) Points
>
"=>"
>= (*)
!=
24. You want to retrieve a list of customers whose last names begin with the le
tters Fr . Which symbol should you include in the WHERE clause of your SELECT st
atement to achieve the desired result? Mark for Review
(1) Points
% (*)
~

#
*
25. 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;
26. Evaluate this SELECT statement:
SELECT *
FROM employees
WHERE 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 (*)
27. You want to retrieve a list of customers whose last names begin with the l
etters 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 (*)
28. 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 empl
oyee 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;
29. You want to create a list of all albums that have been produced by the comp
any. 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;
30. 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;
31. 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
32. What would you use in the SELECT clause to return all the columns in the ta
ble? Mark for Review
(1) Points
An asterisk (*) (*)
A minus sign (-)
A plus sign (+)
The ALL keyword
33. 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 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
34. When you use the SELECT clause to list one or two columns only from a tabl
e and no WHERE clause, which SQL capability is used? Mark for Review
(1) Points
Joining only
Selection only
Projection only (*)
Projection and Selection

35. 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
36. 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 (*)
37. 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
38. 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
39. 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. (*)
40. 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
41. 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.

42. 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;
43. 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.
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.
45. From left to right, what is the correct order of Precedence? Mark for Rev
iew
(1) Points
Arithmetic, Concatenation, Comparison, OR (*)
NOT, AND, OR, Arithmetic
Arithmetic, NOT, Logical, Comparison
Arithmetic, NOT, Concatenation, Logical
46. 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
47. 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.
48. 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. (*)
49. Which of the following best describes the meaning of the LIKE operator? M
ark 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.
50. Which of the following are TRUE regarding the logical AND operator? Mark f
or Review
(1) Points
TRUE AND TRUE return FALSE
TRUE AND FALSE return TRUE
FALSE AND TRUE return NULL
TRUE AND FALSE return FALSE (*)

You might also like