Você está na página 1de 20

eview your answers, feedback, and question scores below.

An asterisk (*) indicates a correct


answer.

Formun Üstü
Semester 1 Final Exam covers Sections 11-17 of Database Design.

Section 11

1. A table must have a primary key. True or False?


Mark for Review
(1) Points

True

False (*)

Correct

2. 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 (*)

Correct

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

4. The text below is an example of what constraint type:


If the number of BOOKS lent to a BORROWER in the Mark for Review
LIBRARY exceeds 5, then we must send him/her a letter (1) Points
requesting the return of the BOOKS, which will require extra
programming to enforce.

Entity integrity

User-defined integrity (*)

Column integrity

Referential integrity

Correct

5. The explanation below is a User Defined integrity rule and must


therefore be manually coded, the Database cannot enforce this Mark for Review
rule automatically:
(1) Points
A primary key must be unique, and no part of the primary key can
be null. True or False?

True

False (*)

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 transformation from an ER diagram to a physical design


involves changing terminology. Secondary Unique Identifiers Mark for Review
become
(1) Points

Columns

Tables

Unique Constraints (*)

Primary Key Constraints

Incorrect. Refer to Section 11 Lesson 2.

9. The Oracle Database can implement a many to many relationship.


You simply create two foreign keys between the two tables. True Mark for Review
or False?
(1) Points

True

False (*)

Correct
10 One-to-One relationships are transformed into Check Constraints
. in the tables created at either end of that relationship. True or Mark for Review
False?
(1) Points

True

False (*)

Correct

Section 11 11. 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

Section 12 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. What command will return data from the database to you? Mark for Review
(1) Points
FETCH
GET

SELECT (*)

RETURN

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 (*)

EVERY

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 (*)

Incorrect. Refer to Section 12 Lesson 2.

16. 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 (*)

Incorrect. Refer to Section 12 Lesson 2.

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.

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
6

8 (*)

10

13
Correct.

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

Section 15 21. 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.

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

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

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

Section 16 25. 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.

26. Which symbol represents the not equal to condition? Mark for Review
(1) Points
#

+'

!= (*)

Correct.

27. Which comparison condition would you use to select rows that match a character

pattern? Mark for Review


(1) Points
IN

LIKE (*)

ALMOST

SIMILAR

Correct.

28. Which operator is used to combine columns of character strings to other

columns? Mark for Review


(1) Points
*

|| (*)

Correct.

29. Where in a SQL statement can you not use arithmetic operators? Mark for
Review
(1) Points
SELECT

FROM (*)

WHERE

NONE

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

Section 16 31. 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.

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

Correct.

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

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

Incorrect. See Section 16 Lesson 2.


35. Any Non-UID must be dependant on the entire UID. True or False? Mark
for Review
(1) Points
True (*)

False

Correct

36. 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 37. Which comparison condition means "Less Than or

Equal To"? Mark for Review


(1) Points
"=)"

"+<"

">="

"<=" (*)

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 logical operator returns TRUE if either condition is true? Mark for
Review
(1) Points
OR (*)

AND

NOT

BOTH

Correct.

40. The ORDER BY clause always comes last. True or False? Mark for Review
(1) Points
True (*)

False

Correct.

Section 17 41. 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.

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

44. 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 employees
WHERE hire_date <= '01-JAN-96';

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


hire_date ||' '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= 01-JAN-96';

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


hire_date ||" / "|| salary Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||' - '|| last_name 'Employee',


hire_date ||' / '|| salary 'Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';

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


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

Correct.

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

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

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;
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 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.
Formun Altı

Você também pode gostar