0% found this document useful (0 votes)
1K views91 pages

Quiz 2

1) The document is a quiz on entity relationship modeling concepts. It contains multiple choice questions about topics like unique identifiers, entity relationship diagrams, cardinality, and relationship optionality. 2) Key concepts covered in the quiz include that a unique identifier uniquely identifies one instance of an entity, ER diagrams show the logical structure of a database, and cardinality specifies how many entities can be related rather than a specific number. 3) Relationship optionality on an ERD is depicted using solid or dashed lines.

Uploaded by

Alex Febian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views91 pages

Quiz 2

1) The document is a quiz on entity relationship modeling concepts. It contains multiple choice questions about topics like unique identifiers, entity relationship diagrams, cardinality, and relationship optionality. 2) Key concepts covered in the quiz include that a unique identifier uniquely identifies one instance of an entity, ER diagrams show the logical structure of a database, and cardinality specifies how many entities can be related rather than a specific number. 3) Relationship optionality on an ERD is depicted using solid or dashed lines.

Uploaded by

Alex Febian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 91

Section 2 Quiz

(Answer all questions in this section)


1. A Unique Identifier has a NULL value for each instance of the entity for the lifetime of
the instance. True or False Mark for Review
(1) Points
True

False (*)

Correct

2. What is the purpose of a Unique Identifier?


Mark for Review
(1) Points
To identify a specific row within a table, using one or more columns and/or foreign
keys.
To identify one unique instance of an entity by using one or more attributes
and/or relationships. (*)
To uniquely determine a table and columns within that table.

Create an entity that is unlike any other entity aside from itself.

Correct

3. The physical model shows all table structures. True or False.


Mark for Review
(1) Points
True (*)

False

Correct

4. The logical model becomes the blueprint for designing the ________ model
Mark for Review
(1) Points
Physical (*)

Network

Data Integrity
Data Flow

Correct

5. Entities are usually _____________.


Mark for Review
(1) Points
Adjectives

Nouns (*)

Verbs

Adverbs

Correct
6. Entity
names Mark for Review
are (1) Points
always
singular.
True or
False?
True (*)

False

Correct

7. To identify an attribute as part of a unique identifier on an ER diagram, the #


symbol goes in front of it. True or False? Mark for Review
(1) Points
True (*)

False

Correct

8. Which of the following is not an advantage of a relational database?


Mark for Review
(1) Points
Efficiency

Data Integrity

One table with all the data. (*)

Less Redundancy

Correct

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


Mark for Review
(1) Points
True (*)

False

Incorrect. Refer to Section 2 Lesson 1.

10. Using ERDish, which wording represents optionality? (Choose Two)


Mark for Review
(1) Points
(Choose all correct answers)
may (*)

mandatory

maybe
must (*)
Incorrect. Refer to Section 2 Lesson 6.
Section 2 Quiz
(Answer all questions in this section)
11. An ERD created using ERDish is a __________ representation of entities and their
relationships to each other. Mark for Review
(1) Points
graphical (*)

textual

hierarchical

technical

Correct

12. The conceptual model does all of the following except:


Mark for Review
(1) Points
Describes the needs of the business.

Documents type of operating system to be used. (*)

Takes into account regulations and laws goverining the industry being addressed.

Prevents mistakes and misunderstandings.

Correct

13. Which of the following are true about Cardinality? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
Cardinality specifies only singularity or plurality, but not a specific plural number.
(*)
Cardinality tells "how many". (*)

Cardinality specifies whether something is required or not.

Cardinality specifies a counting number (like 1, 2, 3, 4 etc.) in a relationship.

Correct

14. The optionality of a relationship must be either _______ or _______.


Mark for Review
(1) Points
Bidirectional or a single direction

Mandatory or Optional (*)

Single or Multiple

One or (One or More)

Correct

15. A __________ relationship is a relationship between an entity and itself.


Mark for Review
(1) Points
Recursive (*)

Mandatory

One to one

Hierarchical

Correct

1. Which of Mark for Review


the (1) Points
following
is not a
goal of
ER
modeling:
It is acceptable to include information that is derivable. (*)
Ensure information appears only once.
Locate information in a logical manner
Capture all required information.
Correct

2. A model is considered to be Implementation-Free if it can be implemented using ____ Mark for Review
of the database software models such as hierarchical, network or relational. (1) Points
any (*)
only one
none
Correct

3. Which of the following statements about entity relationship diagrams (ERD) is true? Mark for Review
(1) Points
Used to communicate the physical structure of the database to users.
Used to communicate the logical structure of the database to users. (*)
Is a hard and fast document that cannot be changed once development of the
database has begun.
Used to communicate the technical specifications of the database to users
Incorrect. Refer to Section 2 Lesson 6.

4. A table must have a primary key. True or False? Mark for Review
(1) Points
True (*)
False
Correct

5. Each column in a relation is called an entity. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 2 Lesson 1.
Page 1 of 3 Next Summary
6. In an ERD, Mark for Review
optionality is (1) Points
depicted using
__________.

solid or dashed lines (*)

single toe or crows foot

names of relationships

soft boxes

Correct

7. The components of a relationship include all of the Mark for Review


following except : (1) Points

Cardinality

Optionality

Relational Integrity (*)

Names

Correct

8. The optionality of a relationship must be either _______ Mark for Review


or _______. (1) Points

Bidirectional or a single direction

One or (One or More)

Mandatory or Optional (*)

Single or Multiple

Correct

9. Which symbol is used to show that a particular attribute is Mark for Review
mandatory? (1) Points

* (*)

o
&

Correct

10. Entities are usually _____________. Mark for Review


(1) Points

Nouns (*)

Verbs

Adverbs

Adjectives

Correct

11. Entity Mark for Review


names (1) Points
are
always
singular.
True or
False?

True (*)

False

Correct

12. An ERD is an example of a ______ Model. Mark for Review


(1) Points

Conceptual (*)

Physical

Data Integrity

Network

Correct

13. Which of the following are reasons we create conceptual models? Mark for Review
(1) Points
It facilitates discussion; a picture is worth a thousand words

It forms important ideal system documentation

It takes into account government regulations and laws

It forms a sound basis for physical database design

All of the above (*)

Correct

14. Unique Identifiers… Mark for Review


(1) Points

Distinguish one entity from another.

Distinguish one instance of an entity from all other instances of that


entity (*)

Distinguish all entities in a database

Distinguish nothing

Correct

15. A candidate UID that does not get chosen to become the primary UID is Mark for Review
called a _________ . (1) Points

Secondary UID (*)

Primary UID

Composite UID

Unique UID

Incorrect. Refer to Section 2 Lesson 4.

Previous Page 3 of 3 Summary


1. In a Mark for Review
relationship (1) Points
,
_________
are used to
helped
describe
the
meaning of
the
connection
between
the
entities.
crows feet
descriptions
names (*)
arrows
Incorrect. Refer to Section 2 Lesson 5.

2. If a relationship is mandatory there must be at least one instance of the Mark for Review
corresponding entity related to it. (1) Points
True (*)
False
Correct

3. One-to-One relationships have _____________ of one to one in both directions. Mark for Review
(1) Points
Optionality
Naming
Foreign Keys
Cardinality (*)
Correct

4. Which of the following would be good as a Unique Identifier for its Entity? (Choose Mark for Review
Three) (1) Points
(Choose all correct answers)
Personal Identification number for Person (*)
Date of birth for Baby
ISBN Number for Book (*)
Vehicle Registration Number for Car (*)
Correct

5. A Unique Identifier has a NULL value for each instance of the entity for the lifetime Mark for Review
of the instance. True or False (1) Points
True
False (*)
Correct

Page 1 of 3 Next Summary

6. Flat file Mark for Review


databases (1) Points
are
generally
in plain-
text form,
where
each line
holds
only one
record.
True or
False?
True (*)
False
Correct

7. A relational database stores information in tables with rows and columns. Mark for Review
(1) Points
True (*)
False
Correct

8. The logical model becomes the blueprint for designing the ________ model Mark for Review
(1) Points
Data Integrity
Physical (*)
Network
Data Flow
Correct

9. The logical model's entities, attributes, unique identifiers and relationships map to the Mark for Review
physical model's _________________. (1) Points
Optionality and Cardinality
Tables, columns, primary keys and foreign keys (*)
Files, records, fields and data values
Correct

10. Using ERDish, which wording represents optionality? (Choose Two) Mark for Review
(1) Points
(Choose all correct answers)
mandatory
maybe
must (*)
may (*)
Correct

Previous Page 2 of 3 Next Summary


11. A model is Mark for Review
considered to be (1) Points
Implementation-
Free if it can be
implemented
using ____ of
the database
software models
such as
hierarchical,
network or
relational.
any (*)

only one

none

Correct

12. Which of the following statements about entity relationship Mark for Review
diagrams (ERD) is true? (1) Points

Used to communicate the logical structure of the database


to users. (*)

Used to communicate the technical specifications of the


database to users

Is a hard and fast document that cannot be changed once


development of the database has begun.

Used to communicate the physical structure of the


database to users.

Incorrect. Refer to Section 2


Lesson 6.

13. To identify an attribute as part of a unique identifier on an Mark for Review


ER diagram, the # symbol goes in front of it. True or False? (1) Points

True (*)

False

Incorrect. Refer to Section 2


Lesson 3.

14. Which of the following entities most likely contains invalid Mark for Review
attributes? (1) Points

Entity: Mother. Attributes: Name, Birthdate, Occupation,


Number of Children

Entity: Pet. Attributes: Name, Birthdate, Owner

Entity: Car. Attributes: Owner Occupation, Owner Salary,


Speed (*)

Entity: Home. Attributes: Number of Bedrooms, Owner,


Address, Date Built
Correct

15. An entity may have which of the following? Mark for Review
(1) Points

Experiences

Instances (*)

Tables

None of the above

Correct

Previous Page 3 of 3 Summary

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 15

(Answer all questions in this section)

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

2. 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 15 Lesson 1.


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

4. 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 15 Lesson 1.

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

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

Section 16

(Answer all questions in this section)

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

Incorrect. See Section 16 Lesson 3.

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

Incorrect. See Section 16 Lesson 2.

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

Incorrect. See Section 16 Lesson 2.


Page 1 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 16

(Answer all questions in this section)

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

Incorrect. See Section 16 Lesson 2.

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

Incorrect. See Section 16 Lesson 2.

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

Incorrect. See Section 16 Lesson 2.


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

Incorrect. See Section 16 Lesson 1.

15. When using the LIKE condition, which symbol represents any sequence of none, one or more
characters? Mark for Review

(1) Points

% (*)

&

Incorrect. See Section 16 Lesson 1.


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

17. Which comparison operator searches for a specified character pattern? Mark for Review

(1) Points

IN

LIKE (*)

BETWEEN...AND...

IS NULL
Incorrect. See Section 16 Lesson 1.

18. Where in a SQL statement can you not use arithmetic operators? Mark for Review

(1) Points

SELECT

FROM (*)

WHERE

NONE

Incorrect. See Section 16 Lesson 1.

19. Which comparison condition would you use to select rows that match a character pattern? Mark
for Review

(1) Points

IN

LIKE (*)

ALMOST

SIMILAR
Incorrect. See Section 16 Lesson 1.

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

Incorrect. See Section 16 Lesson 1.

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 Exam covers Sections 11-17 of Database Design.

Section 12

(Answer all questions in this section)

21. What command will return data from the database to you? Mark for Review

(1) Points

FETCH

GET

SELECT (*)

RETURN

Incorrect. Refer to Section 12 Lesson 1.

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

Incorrect. Refer to Section 12 Lesson 1.

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

Incorrect. Refer to Section 12 Lesson 1.

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

1 (*)

Incorrect. Refer to Section 12 Lesson 2.

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

Section 11

(Answer all questions in this section)

26. In a physical data model, an attribute becomes a _____________. Mark for Review

(1) Points

Table

Foreign Key

Constraint

Column (*)

Incorrect. Refer to Section 11 Lesson 2.

27. 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 11 Lesson 2.

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

Incorrect. Refer to Section 11 Lesson 2.


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

Incorrect. Refer to Section 11 Lesson 1.

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

Incorrect. Refer to Section 11 Lesson 1.

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 Exam covers Sections 11-17 of Database Design.

Section 11

(Answer all questions in this section)

31. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review

(1) Points

True

False (*)

Incorrect. Refer to Section 11 Lesson 1.

32. A table must have a primary key. True or False? Mark for Review

(1) Points
True

False (*)

Incorrect. Refer to Section 11 Lesson 1.

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

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

Incorrect. Refer to Section 11 Lesson 4.

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

Incorrect. Refer to Section 12

Section 17

(Answer all questions in this section)

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

Incorrect! See Section 17 Lesson 2.

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

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

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

50

25 (*)

10

250 (*)

Incorrect! See Section 17 Lesson 2.


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

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

(Answer all questions in this section)

41. 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 17 Lesson 2.

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

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;

Incorrect! See Section 17 Lesson 3.

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;

FROM players

WHERE position_id >= 6900

ORDER BY last_name DESC, first_name;


Correct.

45. 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 17 Lesson 1.

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

Incorrect. See Section 17 Lesson 1.

47. Which comparison condition means ?Less Than or Equal To"? Mark for Review

(1) Points

"=)"

"+<"

">="

"<=" (*)

Incorrect. See Section 17 Lesson 1.

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

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

50. Which logical operator returns TRUE if either condition is true? Mark for Review

(1) Points

OR (*)
AND

NOT

BOTH

Correct.

Page 5 of 5

Section 3 Quiz
(Answer all questions in this section)
1. Evaluate this SELECT statement:
Mark for Review
SELECT * (1) Points
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?
LIKE

BETWEEN AND ...

IN (*)

AND

Correct.

2. Evaluate this SELECT statement:


Mark for Review
SELECT * (1) Points
FROM employees
WHERE salary > 30000
AND department_id = 10
OR email IS NOT NULL;

Which statement is true?


The OR and AND conditions have the same precedence and will be evaluated from
left to right
The OR condition will be evaluated before the AND condition.

The OR and AND conditions have the same precedence and will be evaluated from
right to left
The AND condition will be evaluated before the OR condition. (*)

Correct.

3. Evaluate this SELECT statement:


Mark for Review
SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (1) Points
FROM employees
WHERE salary IS NOT NULL
ORDER BY last_name, 3;

Which clause contains an error?


WHERE salary IS NOT NULL

ORDER BY last_name, 3;

FROM employees

SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*)

Correct.

4. Evaluate this SELECT statement:


Mark for Review
SELECT first_name, last_name, email (1) Points
FROM employees
ORDER BY last_name;

Which statement is true?


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
The rows will not be sorted.

Correct.

5. What clause must you place in a SQL statement to have your results sorted from
highest to lowest salary? Mark for Review
(1) Points
None, the database always sorts from highest to lowest on the salary column.

ORDER BY salary DESC (*)


ORDER salary BY DESC
ORDER BY salary ASC

Incorrect! See Section 3 Lesson 2.


Section 3 Quiz
(Answer all questions in this section)
6. What will be the results of the following selection?
Mark for Review
SELECT * (1) Points
FROM employees
WHERE last_name NOT LIKE 'A%' AND last_name NOT LIKE 'B%'
All last names that begin with A or B

All last names that do not begin with A or B (*)

All rows will be returned

No rows will be returned. There is a syntax error

Correct

7. Which comparison condition means "Less Than or Equal To"?


Mark for Review
(1) Points
"<=" (*)

">="

"=)"

"+<"

Correct.

8. Which logical operator returns TRUE if either condition is true?


Mark for Review
(1) Points
NOT

OR (*)

BOTH

AND

Correct.

9. The ORDER BY clause always comes last. True or False?


Mark for Review
(1) Points
True (*)

False

Correct.

10. Which clause would you include in a SELECT statement to sort the rows returned by
the LAST_NAME column? Mark for Review
(1) Points
WHERE

FROM

ORDER BY (*)

HAVING

Correct.
11. Evaluate this
SQL Mark for Review
statement: (1) Points

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?
Include a HAVING clause.

Reorder the clauses in the query. (*)

Remove the table aliases in the ORDER BY clause.


Remove the table aliases in the WHERE clause.

Correct.

12. The EMPLOYEES table contains these columns:


Mark for Review
EMPLOYEE_ID NUMBER(9) PK (1) Points
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?


One of the statements will eliminate all duplicate DEPARTMENT_ID
values.
The statements will sort on different column values. (*)

There is no difference in the result between the two statements.

One of the statements will return a syntax error.

Incorrect! See Section 3 Lesson 3.

13. The PLAYERS table contains these columns:


Mark for Review
PLAYERS TABLE: (1) Points
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 BETWEEN 24999.99 AND 100000.01
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id DESC, salary DESC;
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 > 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 > 24999.99 AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;
Correct.

14. The following statement represents a multi-row function. True or False?


Mark for Review
SELECT MAX(salary) (1) Points
FROM employees
True (*)

False

Correct

15. The function COUNT is a single row function. True or False?


Mark for Review
(1) Points
True

False (*)

Correct

Section 5

1. Group functions can be nested to a depth of? Mark for Review


(1) Points

Three

Four

Two (*)

Group functions cannot be nested.

Incorrect. Refer to Section 5 Lesson 1.

2. The PLAYERS and TEAMS tables contain these columns:


PLAYERS
PLAYER_ID NUMBER NOT NULL, PRIMARY KEY
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)

TEAMS
TEAM_ID NUMBER NOT NULL, PRIMARY KEY
TEAM_NAME VARCHAR2 (25)

You need to create a report that lists the names of each team with more than three goal keepers.
Which SELECT statement will produce the desired result?
Mark for Review
(1) Points

SELECT t.team_name, COUNT(p.player_id)


FROM players p, teams t
ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name;

SELECT t.team_name, COUNT(p.player_id)


FROM players
JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
HAVING COUNT(p.player_id) > 3;

SELECT t.team_name, COUNT(p.player_id)


FROM players p, teams t
ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name
HAVING COUNT(p.player_id) > 3;

SELECT t.team_name, COUNT(p.player_id)


FROM players p
JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'GOAL KEEPER'
GROUP BY t.team_name
HAVING COUNT(p.player_id) > 3;
(*)

Incorrect. Refer to Section 5 Lesson 1.

3. Evaluate this statement:


SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;

Which clauses restricts the result? Choose two.


Mark for Review
(1) Points

(Choose all correct answers)

SELECT department_id, AVG(salary)

WHERE job_id <> 69879 (*)

GROUP BY job_id, department_id

HAVING AVG(salary) > 35000 (*)

Incorrect. Refer to Section 5 Lesson 1.


4. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
Mark for Review
(1) Points

Displays all the employees and groups them by job.

Displays each job id and the number of people assigned to that job id. (*)

Displays only the number of job_ids.

Displays all the jobs with as many people as there are jobs.

Correct

5. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points

SELECT
FROM
WHERE
ORDER BY
GROUP BY
HAVING

SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)

SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Correct

6. The PAYMENT table contains these columns:


PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)

Which SELECT statement could you use to display the number of times each customer payment was made between
January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points

SELECT customer_id, COUNT(payment_id)


FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)

SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';

SELECT customer_id, COUNT(payment_id)


FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';

SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;

Incorrect. Refer to Section 5 Lesson 1.

7. The PLAYERS table contains these columns:


PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)

Which clauses represent valid uses of aggregate functions? (Choose three.)


Mark for Review
(1) Points

(Choose all correct answers)


ORDER BY AVG(salary) (*)

GROUP BY MAX(salary)

SELECT AVG(NVL(salary, 0)) (*)

HAVING MAX(salary) > 10000 (*)

WHERE hire_date > AVG(hire_date)

Incorrect. Refer to Section 5 Lesson 1.

8. The MANUFACTURER table contains these columns:


MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER

You need to display the number of unique types of manufacturers at each location. Which SELECT statement should
you use?
Mark for Review
(1) Points

SELECT location_id, COUNT(DISTINCT type)


FROM manufacturer
GROUP BY location_id;
(*)

SELECT location_id, COUNT(DISTINCT type)


FROM manufacturer;

SELECT location_id, COUNT(type)


FROM manufacturer
GROUP BY location_id;

SELECT location_id, COUNT(DISTINCT type)


FROM manufacturer
GROUP BY type;

Correct

9. The PRODUCTS table contains these columns:


PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER

You display the total of the extended costs for each product category by location.
You need to include only the products that have a price less than $25.00.
The extended cost of each item equals the quantity value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points

SELECT category_id, SUM(cost * quantity) TOTAL,location_id


FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;

SELECT SUM(cost * quantity) TOTAL, location_id


FROM products
WHERE price < 25.00 <br /> GROUP BY location_id;

SELECT category_id, SUM(cost * quantity) TOTAL, location_id


FROM products
WHERE price < 25.00 <br /> GROUP BY category_id, location_id;
(*)

SELECT SUM(cost * quantity) TOTAL


FROM products
WHERE price < 25.00;

Incorrect. Refer to Section 5 Lesson 1.

10. Evaluate this SELECT statement:


SELECT COUNT(employee_id), department_id
FROM employees
GROUP BY department_id;

You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points

WHERE salary > 15000 (*)

HAVING salary > 15000

WHERE SUM(salary) > 15000

HAVING SUM(salary) > 15000


Correct

Page 1 of 5

Test: Mid-Term Exam Semester 2 Part Two

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

Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL.

Section 5
(Answer all questions in this section)

11. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points

Salaries cannot be averaged as not all the numbers will divide evenly.

You cannot use a column alias in the GROUP BY clause. (*)

The GROUP BY clause must have something to GROUP.

The department id is not listed in the departments table.

Correct

12. Evaluate this SELECT statement:


SELECT MIN(hire_date), deptartment_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points

The earliest hire date in each department. (*)

The the earliest hire date in the EMPLOYEES table.


The latest hire date in the EMPLOYEES table.

The hire dates in the EMPLOYEES table that contain NULL values.

Correct

13. Evaluate this SELECT statement:


SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;
Which values are displayed?
Mark for Review
(1) Points

The highest salary for all employees.

The highest salary in each department. (*)

The employees with the highest salaries.

The employee with the highest salary for each department.

Correct

14. You use GROUPING function to: Mark for Review


(1) Points

Produce subtotal and cross-tabulated values

Identify the extra row values created by either a ROLLUP or CUBE operation (*)

Aggregate rows using SUM, MIN, MAX, and COUNT

Incorrect. Refer to Section 5 Lesson 2.

15. CUBE can be applied to all aggregate functions including AVG, SUM, MIN, MAX, and COUNT. True or False? Mark
for Review
(1) Points

True (*)

False

Incorrect. Refer to Section 5 Lesson 2.

16. You use ROLLUP to: Mark for Review


(1) Points

produce subtotal values (*)

cross-tabulate values

produce a single result set

Incorrect. Refer to Section 5 Lesson 2.

17. You use GROUPING function to ______ database rows from tabulated rows. Mark for Review
(1) Points

CREATE

DISTINGUISH (*)

COMPUTE

COUNT

Correct

18. When using SET operators the names of the columns must be identified in all of the SELECT statements used in
the query. True or False? Mark for Review
(1) Points

True

False (*)

Correct

19. To control the order of rows returned using SET operators, the ORDER BY clause is used ______ and is placed in
the _____ SELECT statement of the query. Mark for Review
(1) Points

ONCE; FIRST

TWICE; FIRST

ONCE; LAST (*)

IN ALL; LAST

Correct
Section 7
(Answer all questions in this section)

20. The EMPLOYEES table contains the following columns:


EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPTARTMENT_ID VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)

You need to increase the salary for all employees in department 10 by 10 percent. You also need to increase the
bonus for all employees in department 10 by 15 percent. Which statement should you use?
Mark for Review
(1) Points

UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE department_id = 10;
(*)

UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE department_id = 10;

UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE department_id = 10;

UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE department_id = 10;

Correct

Page 2 of 5

Test: Mid-Term Exam Semester 2 Part Two


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

Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL.

Section 7
(Answer all questions in this section)

21. What would happen if you issued a DELETE statement without a WHERE clause? Mark for Review
(1) Points

All the rows in the table would be deleted. (*)

An error message would be returned.

No rows would be deleted.

Only one row would be deleted.

Incorrect. Refer to Section 7 Lesson 2.

22. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points

INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;

INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';

INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)

INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;

Incorrect. Refer to Section 7 Lesson 2.

23. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one
UPDATE statement. Which clause should you include in the UPDATE statement to update multiple columns? Mark for
Review
(1) Points

The USING clause

The ON clause

The WHERE clause

The SET clause (*)


Incorrect. Refer to Section 7 Lesson 2.

24. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)

MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER

TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)

Which situation would require a subquery to return the desired result?


Mark for Review
(1) Points

To display the names each player on the Lions team

To display the maximum and minimum player salary for each team

To display the names of the managers for all the teams owned by a given owner (*)

To display each player, their manager, and their team name for all teams with a id value greater than 5000

Incorrect. Refer to Section 7 Lesson 2.

25. The EMPLOYEES table contains the following columns:


EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FAST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)

You want to execute one DML statement to change the salary of all employees in department 10 to equal the new
salary of employee number 89898. Currently, all employees in department 10 have the same salary value. Which
statement should you execute?
Mark for Review
(1) Points
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;

UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);

UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)

UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id = 10);

Incorrect. Refer to Section 7 Lesson 2.

26. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:


TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)

CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)

Which scenario would require a subquery to return the desired results?


Mark for Review
(1) Points

You need to display the start date for each class taught by a given teacher.

You need to create a report to display the teachers who were hired more than five years ago.

You need to display the names of the teachers who teach classes that start within the next week.

You need to create a report to display the teachers who teach more classes than the average number of classes
taught by each teacher. (*)

Correct

27. You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee identification
number is 348. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)

Which DELETE statement will delete the appropriate record without deleting any additional records?
Mark for Review
(1) Points

DELETE FROM employees


WHERE employee_id = 348;
(*)

DELETE FROM employees


WHERE last_name = jones;

DELETE *
FROM employees
WHERE employee_id = 348;

DELETE 'jones'
FROM employees;

Incorrect. Refer to Section 7 Lesson 2.

28. The PRODUCTS table contains these columns:


PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)

You want to add the following row data to the PRODUCTS table:

(1) a NULL value in the PROD_ID column


(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column

You issue this statement:

INSERT INTO products


VALUES (null,'6-foot nylon leash', 10);

What row data did you add to the table?


Mark for Review
(1) Points

The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.

The row was created with the correct data in one of the three columns.

The row was created completely wrong. No data ended up in the correct columns.

Incorrect. Refer to Section 7 Lesson 1.

29. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table. What could you use in the
INSERT statement to accomplish this task? Mark for Review
(1) Points

An ON clause

A SET clause

A subquery (*)

A function

Incorrect. Refer to Section 7 Lesson 1.

30. The PRODUCTS table contains these columns:


PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER NOT NULL
LIST_PRICE NUMBER (7,2)
COST NUMBER (5,2)
QTY_IN_STOCK NUMBER(4)
LAST_ORDER_DT DATE NOT NULL DEFAULT SYSDATE

Which INSERT statement will execute successfully?


Mark for Review
(1) Points

INSERT INTO products


VALUES (2958, 'Cable', 8690, 7.09, 4.04, 700);
(*)

INSERT INTO products


VALUES (2958, 'Cable', 8690, 7.09, 4.04, SYSDATE);

INSERT INTO products(product_id, product_name)


VALUES (2958, 'Cable');

INSERT INTO products(product_id, product_name, supplier_id


VALUES (2958, 'Cable', 8690, SYSDATE);
Incorrect. Refer to Section 7 Lesson 1.

Page 3 of 5

Test: Mid-Term Exam Semester 2 Part Two

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

Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL.

Section 7
(Answer all questions in this section)

31. Assume all the column names are correct. The following SQL statement will execute which of the following?
INSERT INTO departments (department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
Mark for Review
(1) Points

100 will be inserted into the department_id column

1700 will be inserted into the manager_id column

70 will be inserted into the department_id column (*)

?Public Relations? will be inserted into the manager_name column

Correct

32. Aliases can be used with MERGE statements. True or False? Mark for Review
(1) Points

True (*)

False

Incorrect. Refer to Section 7 Lesson 3.

33. Multi-table inserts are used when the same source data should be inserted into _____________ target table.
Mark for Review
(1) Points

Ten

A very large

More than one (*)

A data warehouse

Correct

Section 6
(Answer all questions in this section)

34. A correlated subquery is evaluated _____ for each row processed by the parent statement. Mark for Review
(1) Points

EVERY TIME

ONCE (*)

COMPLETELY

Correct

35. A correlated subquery will _______ a candidate row from an outer query, _______ the inner query using
candidate row value, and _______ values from the inner query to qualify or disqualify the candidate row. Mark for
Review
(1) Points

CREATE; EXECUTE; USE

DELETE; UPDATE; INSERT

GET; EXECUTE; USE (*)

ROLLUP; GRANT; DROP

Incorrect. Refer to Section 6 Lesson 4.

36. Which statement is false? Mark for Review


(1) Points

The WITH clause retrieves the results of one or more query blocks
The WITH clause decreases performance (*)

The WITH clause makes the query simple to read

The WITH clause stores the results for the user who runs the query

Incorrect. Refer to Section 6 Lesson 4.

37. The WITH clause enables a SELECT statement to define the subquery block at the start of the query, process the
block just once, label the results, and then refer to the results multiple times. True or False? Mark for Review
(1) Points

True (*)

False

Incorrect. Refer to Section 6 Lesson 4.

38. Which comparison operator can only be used with a single-row subquery? Mark for Review
(1) Points

ANY

ALL

<> (*)

IN

Correct

39. You need to produce a report that contains all employee-related information for those employees who have Brad
Carter as a supervisor. However, you are not sure which supervisor ID belongs to Brad Carter. Which query should
you issue to accomplish this task? Mark for Review
(1) Points

SELECT *
FROM employees
WHERE supervisor_id = (SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');

SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
FROM supervisors
WHERE last_name = 'Carter');

SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)

Incorrect. Refer to Section 6 Lesson 2.

40. What would happen if you attempted to use a single-row operator with a multiple-row subquery? Mark for
Review
(1) Points

An error would be returned. (*)

No rows will be selected.

All the rows will be selected.

The data returned may or may not be correct.

Correct

Page 4 of 5

Test: Mid-Term Exam Semester 2 Part Two

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

Semester 2 Mid Term Exam Part II covers Sections 5-7 of Database Programming with SQL.
Section 6
(Answer all questions in this section)

41. You are looking for Executive information using a subquery.


What will the following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id FROM departments WHERE department_name = 'Executive');
Mark for Review
(1) Points

The department ID, department name and last name for every employee in the Executive department.

The department ID, last name, department name for every Executive in the employees table.

The department ID, last name, job ID from departments for Executive employees.

The department ID, last name, job ID for every employee in the Executive department. (*)

Incorrect. Refer to Section 6 Lesson 3.

42. A multiple-row operator expects how many values? Mark for Review
(1) Points

One or more (*)

Only one

Two or more

None

Correct

43. If you use the equality operator (=) with a subquery, how many values can the subquery return? Mark for
Review
(1) Points

Only 1 (*)

Up to 2

Up to 5

Unlimited

Correct
44. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY

ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)

Which of the following scenarios would require a subquery to return the desired results?
Mark for Review
(1) Points

You need to display the date each customer account was opened.

You need to display each date that a customer placed an order.

You need to display all the orders that were placed on a certain date.

You need to display all the orders that were placed on the same day as order number 25950. (*)

Incorrect. Refer to Section 6 Lesson 1.

45. You need to create a report to display the names of products with a cost value greater than the average cost of
all products. Which SELECT statement should you use? Mark for Review
(1) Points

SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost)
FROM product);
(*)

SELECT product_name
FROM products
WHERE cost > AVG(cost);

SELECT AVG(cost), product_name


FROM products
WHERE cost > AVG(cost)
GROUP by product_name;

SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Incorrect. Refer to Section 6 Lesson 1.

46. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points

IN (*)

<>

LIKE

Correct

47. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:


TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)

CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
DATE
MAX_CAPACITY NUMBER (3)

All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries? (Choose two.)
Mark for Review
(1) Points

(Choose all correct answers)

SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)

SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id = 45963);
(*)

SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id, class_assignments WHERE max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity > 1000);

SELECT *
FROM class_assignments
max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY teacher_id);

Incorrect. Refer to Section 6 Lesson 1.

48. The EMPLOYEES and ORDERS tables contain these columns:


EMPLOYEES
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)

ORDERS

ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY


EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)

Which SELECT statement will return all orders generated by a sales representative named Franklin during the year
2001?
Mark for Review
(1) Points

SELECT order_id, total


FROM ORDERS (SELECT employee_id
FROM employees
WHERE last_name = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';

SELECT (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';

SELECT order_id, employee_id, total


FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)

Correct

49. You need to display all the players whose salaries are greater than or equal to John Brown's salary. Which
comparison operator should you use? Mark for Review
(1) Points

>

<=

>= (*)

Incorrect. Refer to Section 6 Lesson 1.

50. Which operator can be used with subqueries that return only one row? Mark for Review
(1) Points

LIKE (*)

ANY

ALL

IN

Incorrect. Refer to Section 6 Lesson 1.

1. When you resolve a M:M, you simply re-draw the relationships between the
two original entities; no new entities are created. True or False? Mark for Review

(1) Points

True
False (*)

Correct Correct

2. Another name for a "barred relationship" is ________________. Mark for


Review

(1) Points

Supertype Relationship

Identifying Relationship (*)

Recursive Relationship

Hierarchical Relationship

Incorrect Incorrect. Refer to Section 3 Lesson 1.


3. How many subtypes can a supertype have? Mark for Review

(1) Points

zero

two

any number (*)

one

Correct Correct

4. If a relationship can NOT be moved between instances of the entities it


connects, it is said to be: Mark for Review

(1) Points

Mandatory

Transferable
Optional

Non-Transferable (*)

Correct Correct

5. A ___________ relationship is created when the UID for an entity includes the
relationship with another entity. Mark for Review

(1) Points

recursive

one to one

many to many

barred (*)

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

Unique Keys, Primary keys

Primary keys, Foreign keys (*)

Foreign keys, mandatory business rules

Foreign keys, Primary keys

Correct Correct

7. An entity name is converted to a table name by making it plural. Mark for


Review

(1) Points

True (*)

False
Incorrect Incorrect. Refer to Section 3 Lesson 4.

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

Foreign Key (*)

Primary Key or Unique Key (*)

Check Constraint or Unique Key

Correct Correct
9. A new system would have a mixture of both Procedural and Structural Business
Rules as part of the documentation of that new system. True or False? Mark for Review

(1) Points

True (*)

False

Correct Correct

10. Why is it important to follow the rules of normalization? Mark for Review

(1) Points

To reduce redundant data in the existing design

To increase the integrity of data and the design's stability

To eliminate other types of data inconsistencies and anomalies

To identify missing tables, columns, and constraints


All of the above. (*)

Incorrect Incorrect. Refer to Section 3 Lesson 3.

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 attributes with repeating or multi-values are removed.

When no attritibutes are mutually independent and all are fully dependent on the primary key.

None of the Above.

Correct Correct
12. Would it be a good idea to model age as an attribute of STUDENT? Mark
for Review

(1) Points

Sometimes, but not all of the time

Yes

No - it is a volatile attribute (*)

Yes, it would prevent our having to calculate someone's age every time we need it.

Correct Correct

13. A table is in 2NF if Mark for Review

(1) Points

It meets the requirements for the 1 NF.

Each non-key attribute is fully functional dependent on the table's primary key.
Both A and B must be true. (*)

Neither A or B must be true.

Incorrect Incorrect. Refer to Section 3 Lesson 3.

14. A ______________ is frequently used to track information about a relationship


that changes over time. Mark for Review

(1) Points

non-transferable relationship

many to many relationship

intersection entity (*)

recursive relationship
Incorrect Incorrect. Refer to Section 3 Lesson 2.

15. Which of the following would be a logical constraint when modeling time for a
City entity? Mark for Review

(1) Points

If you are doing a system for any French City, you would need security clearance.

Daily traffic patterns must be monitored to determine how many law enforcement officers are
needed.

Cites may change their names and/or country association if the borders of a country change. (*)

People are born in the city and people die in the city.

Correct Correct

11. Which of the following statements about subtypes is not true? Mark for Review

(1) Points
Inherits all attributes of the supertype.

Never exists alone.

Must have subtypes of its own. (*)

Inherits all relationships of the supertype.

Incorrect Incorrect. Refer to Section 3 Lesson 1.

12. The "Other" subtype is mandatory. True or False? Mark for Review

(1) Points

True

False (*)

Incorrect Incorrect. Refer to Section 3 Lesson 1.


13. Which of the following pairs of entities is most likely to be modeled as a M:M
relationship? Mark for Review

(1) Points

PERSON and FINGERPRINT

CAR and WHEEL

TEACHER and SUBJECT AREA (*)

TREE and BRANCH

Incorrect Incorrect. Refer to Section 3 Lesson 1.

14. Intersection Entities are at the ______ end of the newly created 1:M
(Parent:Child) relationship; Mark for Review

(1) Points

Single
Barred

Parent

Child (*)

Incorrect Incorrect. Refer to Section 3 Lesson 1.

15. What do you call the entity created when you resolve a M:M relationship?
Mark for Review

(1) Points

M:M entity

Inclusion entity

Intersection entity (*)


Recursive entity

6. An entity
without Mark for Review
repeated (1) Points
values is
said to be in
__________.
2nd normal form

3rd normal form

4th normal form

1st normal form (*)

Correct

7. A table is in 3NF if it has met all database requirements for both 1NF and 2NF
and all transitive dependencies are eliminated. Mark for Review
(1) Points
True (*)

False

Correct

8. Normalizing an Entity to 1st Normal Form is done by removing any attributes


that contain muliple values. True or False? Mark for Review
(1) Points
True (*)

False

Correct

9. Why is it important to follow the rules of normalization?


Mark for Review
(1) Points
To reduce redundant data in the existing design

To increase the integrity of data and the design's stability

To eliminate other types of data inconsistencies and anomalies

To identify missing tables, columns, and constraints

All of the above. (*)

Correct

10. The Rule of 3rd Normal Form states that No Non-UID attribute can be
dependent on another non-UID attribute. True or False? Mark for Review
(1) Points
True (*)
False

Correct
1. The
transformation Mark for Review
from an ER (1) Points
diagram to a
physical
design
involves
changing
terminology.
Secondary
Unique
Identifiers
become
_____.
Tables

Unique Constraints (*)

Columns

Primary Key Constraints

Correct

2. When mapping entities containing supertypes and subtypes a _________


table implementation is used when most of the attributes and relationships Mark for Review
are shared at the supertype level. (1) Points

two-table

many to many

single-table (*)

multiple-table

Correct

3. The transformation from an ER diagram to a physical design involves


changing terminology. Primary Unique Identifiers in the ER diagram become Mark for Review
__________ and relationships become ____________. (1) Points

Foreign keys, Primary keys

Unique Keys, Primary keys

Primary keys, Foreign keys (*)

Foreign keys, mandatory business rules

Correct

4. A ______________ is frequently used to track information about a


relationship that changes over time. Mark for Review
(1) Points
recursive relationship
intersection entity (*)
non-transferable relationship

many to many relationship

Correct

5. Modeling historical data can produce a unique identifier that includes dates.
True or False? Mark for Review
(1) Points
True (*)

False

You might also like