Guide To SQL 8th Edition Pratt Test Bank

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Guide To SQL 8th Edition Pratt Test

Bank
Visit to download the full and correct content document:
https://testbankdeal.com/download/guide-to-sql-8th-edition-pratt-test-bank/
Chapter 5: Multiple-Table Queries

TRUE/FALSE

1. When joining tables, it is always necessary to qualify a column name.

ANS: F PTS: 1 REF: 136

2. You can join tables by using a condition in the WHERE clause.

ANS: T PTS: 1 REF: 136

3. To ensure that query results are listed in a desired order, use the ORDER BY clause.

ANS: T PTS: 1 REF: 136

4. To relate two tables, in the FROM clause list all columns involved in the query.

ANS: F PTS: 1 REF: 136

5. You must join tables by finding rows in the two tables that have identical values in matching columns.

ANS: T PTS: 1 REF: 136

6. It is permissable to qualify all column names in a query.

ANS: T PTS: 1 REF: 137

7. There is only one approach to joining tables.

ANS: F PTS: 1 REF: 139

8. You can use the EXISTS operator to retrieve data from more than one table.

ANS: T PTS: 1 REF: 139

9. You can use the IN operator to retrieve data from multiple tables..

ANS: T PTS: 1 REF: 140

10. When the innermost subquery is evaluated, a permanent table is produced.

ANS: F PTS: 1 REF: 143

11. In a nested query, the outer query is evaluated first.

ANS: F PTS: 1 REF: 143

12. In small databases, there is a significant time difference between different query approaches.

ANS: F PTS: 1 REF: 144


13. When using a DBMS without an optimizer, the formulation of a query can make a difference in the
speed with which the query is executed..

ANS: T PTS: 1 REF: 144

14. You must use a comma or a period to separate a table name from its alias.

ANS: F PTS: 1 REF: 146

15. One reason for using an alias is simplicity.

ANS: T PTS: 1 REF: 146

16. One reason for using an alias is when you are joining a table to itself.

ANS: T PTS: 1 REF: 147

17. Occasionally, a self-join might involve the primary key of a table.

ANS: T PTS: 1 REF: 148

18. You can join three tables together but not four tables.

ANS: F PTS: 1 REF: 151

19. For two tables to be union compatible, the columns of the two tables must be identical.

ANS: F PTS: 1 REF: 153

20. Oracle supports the INTERSECT operator.

ANS: T PTS: 1 REF: 155

21. To produce the same results as the INTERSECT operator, use the BETWEEN operator and a
subquery.

ANS: F PTS: 1 REF: 155

22. To produce the same results as the MINUS operator, use NOT, the IN operator and a subquery.

ANS: T PTS: 1 REF: 156

23. SQL Server does not support the MINUS operator.

ANS: T PTS: 1 REF: 157

24. You can use the ALL and ANY operators with subqueries to produce a single column of numbers.

ANS: T PTS: 1 REF: 157

25. You can perform special operations, such an self-joins, within SQL.

ANS: T PTS: 1 REF: 160


26. There are three types of inner joins.

ANS: F PTS: 1 REF: 161

27. In a full outer join, all rows from both tables will be included regardless of whether they match rows
from the other table.

ANS: T PTS: 1 REF: 161

28. The product operation is commonly used.

ANS: F PTS: 1 REF: 163

29. It is easy to create a product inadvertently by omitting the WHERE clause when you are attempting to
join tables.

ANS: T PTS: 1 REF: 163

30. Table A has 10 rows and table B has 10 rows. The product of Table A and Table B would have 100
rows.

ANS: T PTS: 1 REF: 164

MULTIPLE CHOICE

1. You can join tables by using a condition in the ____ clause.


a. FROM c. SELECT
b. WHERE d. JOIN
ANS: B PTS: 1 REF: 136

2. To qualify a column name, precede the name of the column with the name of the table, followed by
a(n) ____.
a. comma (,) c. percent sign (%)
b. period (.) d. asterisk (*)
ANS: B PTS: 1 REF: 136

3. To retrieve data from multiple tables in a query you can use the ____ operator with a subquery.
a. AND c. OR
b. IN d. NOT
ANS: B PTS: 1 REF: 140

4. You can precede a subquery with the ____ operator to create a condition that is true if one or more
rows are obtained when the subquery is executed.
a. IS NULL c. IS EXIST
b. IS TRUE d. EXISTS
ANS: D PTS: 1 REF: 142

5. When a subquery involves a table listed in the outer query, the subquery is called a(n) ____ subquery.
a. inner outer c. reverse
b. correlated d. parameter
ANS: B PTS: 1 REF: 142

6. A(n) ____ clause can include statistics calculated for only the groups or columns whose values are
identical for each row in a group.
a. SELECT c. FROM
b. WHERE d. EXISTS
ANS: A PTS: 1 REF: 145

7. You create an alias by typing the name of the table, pressing the ____, and then typing the name of the
alias.
a. Tab c. Enter
b. Backspace d. Spacebar
ANS: D PTS: 1 REF: 146

8. The ____ of two tables is a table containing every row that is in either the first table, the second table,
or both tables.
a. intersection c. minus
b. union d. difference
ANS: B PTS: 1 REF: 152

9. The ____ of two tables is a table containing all rows that are in both tables.
a. intersect c. difference
b. union d. minus
ANS: A PTS: 1 REF: 152

10. The ____ of two tables is the set of all rows that are in the first table but that are not in the second
table.
a. union c. intersection
b. intersect d. difference
ANS: D PTS: 1 REF: 152

11. Two tables are ____ compatible if they have the same number of columns and if their corresponding
columns have identical data types and lengths.
a. union c. difference
b. minus d. intersect
ANS: A PTS: 1 REF: 153

12. For an SQL implementation to truly support the union operation, it must remove ____ rows
automatically.
a. dependent c. independent
b. no d. duplicate
ANS: D PTS: 1 REF: 154

13. Oracle and SQL Server support the ____ operator but Microsoft Access does not.
a. UNION c. MINUS
b. INTERSECT d. ALL
ANS: B PTS: 1 REF: 156
14. If you precede the subquery by the ____ operator, the condition is true only if it satisfies all values
produced by the subquery.
a. TRUE c. IS ALL
b. ALL d. ALWAYS
ANS: B PTS: 1 REF: 157

15. If you precede the subquery by the ____ operator, the condition is true only if it satisfies any value
(one or more) produced by the subquery.
a. IS SOME c. SOME
b. IS ANY d. ANY
ANS: D PTS: 1 REF: 157

16. Which of the following joins compares the tables in the FROM clause and lists only those rows that
satisfy the condition in the WHERE clause?
a. inner c. nested
b. outer d. product
ANS: A PTS: 1 REF: 160

17. In a(n) ____ join, all rows from both tables are included regardless of whether they match rows from
the other table.
a. normal c. full outer
b. inner d. combined
ANS: C PTS: 1 REF: 161

18. In a ____, all rows from the table on the left (the table listed first in the query) will be included
regardless of whether they match rows from the table on the right (the table listed second in the query).
a. left inner join c. right inner join
b. left outer join d. right outer join
ANS: B PTS: 1 REF: 161

19. In a ____, all rows from the table on the right will be included regardless of whether they match rows
from the table on the left.
a. left inner join c. right outer join
b. left outer join d. right inner join
ANS: C PTS: 1 REF: 161

20. The product of two tables is formally called the ____ Product.
a. Oracle c. SQL
b. Outer d. Cartesian
ANS: D PTS: 1 REF: 163

COMPLETION

1. To retrieve data from more than one table, you must ____________________ the tables together by
finding rows in the two tables that have identical values in matching columns.

ANS: join
PTS: 1 REF: 136

2. You join tables in SQL by including a condition in the ____________________ clause to ensure that
matching columns contain equal values.

ANS: WHERE

PTS: 1 REF: 136

3. When there is potential ambiguity in listing column names, you must ____________________ the
columns involved in the query.

ANS: qualify

PTS: 1 REF: 137

4. The subquery that involves a table listed in the outer query is called a(n) ____________________
subquery.

ANS: correlated

PTS: 1 REF: 142

5. A subquery within a subquery is called a(n) ____________________ subquery.

ANS: nested

PTS: 1 REF: 142

6. SQL performs many built-in ____________________ that analyze queries to determine the best way
to satisfy them.

ANS: optimizations

PTS: 1 REF: 144

7. When tables are listed in the FROM clause, you can give each table a(n) ____________________, or
an alternate name.

ANS: alias

PTS: 1 REF: 146

8. Joining a table to itself is called a(n) ____________________.

ANS: self-join

PTS: 1 REF: 147

9. If you had two separate tables for customers and the query requested customers in the first table having
the same city as customers in the second table, you could use a normal ____________________
operation to find the answer.

ANS: join
PTS: 1 REF: 147

10. In a multiple-table query, you list all the desired columns in the ____________________ clause and
qualify any columns that appear in more than one table.

ANS: SELECT

PTS: 1 REF: 152

11. The ____________________ of two tables is a table containing every row that is in either the first
table, the second table, or both tables.

ANS: union

PTS: 1 REF: 152

12. The ____________________ of two tables is a table containing all rows that are in both tables.

ANS:
intersection
intersect

PTS: 1 REF: 152

13. The ____________________ of two tables is the set of all rows that are in the first table but that are
not in the second table.

ANS:
difference
minus

PTS: 1 REF: 152

14. Two tables are ____________________ compatible if they have the same number of columns and if
their corresponding columns have identical data types and lengths.

ANS: union

PTS: 1 REF: 153

15. If the SQL implementation truly supports the union operation, it will remove any duplicate
____________________ automatically.

ANS: rows

PTS: 1 REF: 154

16. If you precede a subquery by the ____________________ operator, the condition is true only if it
satisfies all values produced by the subquery.

ANS: ALL

PTS: 1 REF: 157


17. If you precede a subquery by the ____________________ operator, the condition is true only if it
satisfies one or more values produced by the subquery.

ANS: ANY

PTS: 1 REF: 157

18. A join that compares the tables in the FROM clause and lists only those rows that satisfy the condition
in the WHERE clause is called a(n) ____________________ join.

ANS: inner

PTS: 1 REF: 160

19. Sometimes you need to list all the rows from one of the tables in a join, regardless of whether they
match any rows in the other table. This type of join is called a(n) ____________________ join.

ANS: outer

PTS: 1 REF: 161

20. The ____________________ of two tables is the combination of all rows in the first table and all rows
in the second table.

ANS:
product
Cartesian Product

PTS: 1 REF: 163

ESSAY

1. What steps should you take to construct the SQL command to join (relate) tables?

ANS:
1. In the SELECT clause, list all columns you want to display.
2. In the FROM clause, list all tables involved in the query.
3. In the WHERE clause, list the condition that restricts the data to be retrieved to only those rows
from the two tables that match; that is, restrict it to the rows that have common values in matching
columns.

PTS: 1 REF: 136

2. What steps should you take to construct a detailed query in a step-by-step fashion?

ANS:
1. List in the SELECT clause all the columns that you want to display. If the name of a column
appears in more than one table, precede the column name with the table name.
2. List in the FROM clause all the tables involved in the query. Usually you include the tables that
contain the columns listed in the SELECT clause. Occasionally, however, there might be a table that
does not contain any columns used in the SELECT clause but that does contain columns used in the
WHERE clause. In this case, you must also list the table in the FROM clause.
3. Take one pair of related tables at a time and indicate in the WHERE clause the condition that relates
the tables. Join these conditions with the AND operator. If there are any other conditions, include them
in the WHERE clause and connect them to the other conditions with the AND operator.

PTS: 1 REF: 152

3. There are three set operations: union, intersection, difference. Define each of these operations. Which
are supported by Oracle?

ANS:
The union of two tables creates a temporary table containing every row that is in either the first table,
the second table, or both tables. The intersection of two tables creates a temporary table containing all
rows that are in both tables. the difference of two tables creates a temporary table containing the set of
all rows that are in the first table but that are not in the second table. Oracle supports all three set
operators.

PTS: 1 REF: 152|156

4. Why do you use the ANY and ALL operators? What is the difference between the two operators?

ANS:
You can use the ALL and ANY operators with subqueries to produce a single column of numbers. If
you precede the subquery by the ALL operator, the condition is true only if it satisfies all values
produced by the subquery. If you precede the subquery by the ANY operator, the condition is true only
if it satisfies any value (one or more) produced by the subquery.

PTS: 1 REF: 157

5. Describe the types of outer joins.

ANS:
There are actually three types of outer joins. In a left outer join, all rows from the table on the left (the
table listed first in the query) will be included regardless of whether they match rows from the table on
the right (the table listed second in the query). Rows from the table on the right will be included only if
they match. In a right outer join, all rows from the table on the right will be included regardless of
whether they match rows from the table on the left. Rows from the table on the left will be included
only if they match. In a full outer join, all rows from both tables will be included regardless of whether
they match rows from the other table.

PTS: 1 REF: 161

You might also like