Chapter 6

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

Modern Database Management, 13e (Hoffer)

Chapter 6 Advanced SQL

1) The ________ operator is used to combine the output from multiple queries into a single result
table.
A) INTERSECT
B) DIVIDE
C) COLLATE
D) UNION
Answer: D
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

2) A ________ is a temporary table used in the FROM clause of an SQL query.


A) correlated subquery
B) derived table
C) view table
D) trigger
Answer: B
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

3) In order for two queries to be UNION-compatible, they must:


A) both have the same number of lines in their SQL statements.
B) both output compatible data types for each column and return the same number of rows.
C) both return at least one row.
D) both return exactly one row.
Answer: B
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

4) The UNION clause is used to:


A) combine the output from multiple queries into a single result table.
B) join two tables together to form one table.
C) find all rows that do not match in two tables.
D) find all rows that are in one table, but not the other.
Answer: A
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology
1
Copyright © 2019 Pearson Education, Inc.
5) Establishing IF-THEN-ELSE logical processing within an SQL statement can be
accomplished by:
A) using the if-then-else construct.
B) using the immediate if statement.
C) using the CASE key word in a statement.
D) using a subquery.
Answer: C
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

6) All of the following are guidelines for better query design EXCEPT:
A) understand how indexes are used in query processing.
B) use a lot of self-joins.
C) write simple queries.
D) retrieve only the data that you need.
Answer: B
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Difficult
Classification: Concept
AACSB: Information Technology

7) A join operation:
A) brings together data from two different fields.
B) causes two tables with a common domain to be combined into a single table or view.
C) causes two disparate tables to be combined into a single table or view.
D) is used to combine indexing operations.
Answer: B
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

8) A join in which the joining condition is based on equality between values in the common
columns is called a(n):
A) equi-join.
B) unilateral join.
C) natural join.
D) both A and C.
Answer: D
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

2
Copyright © 2019 Pearson Education, Inc.
9) The following code is an example of a(n):

SELECT Customer_T.CustomerID, Order_T.CustomerID,


CustomerName, OrderID
FROM Customer_T, Order_T
WHERE Customer_T.CustomerID = Order_T. CustomerID;

A) equi-join.
B) subquery.
C) Full Outer JOIN.
D) Right Outer JOIN.
Answer: A
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

10) The following code would include:

SELECT Customer_T.CustomerID,CustomerName, OrderID


FROM Customer_T RIGHT OUTER JOIN Order_T ON
Customer_T.CustomerID = Order_T.CustomerID;

A) all rows of the Order_T Table regardless of matches with the Customer_T Table.
B) all rows of the Customer_T Table regardless of matches with the Order_T Table.
C) only rows that match both Customer_T and Order_T Tables.
D) only rows that don't match both Customer_T and Order_T Tables.
Answer: A
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

3
Copyright © 2019 Pearson Education, Inc.
11) The following code would include:

SELECT Customer_T.CustomerID,CustomerName, OrderID


FROM Customer_T LEFT OUTER JOIN Order_T ON
Customer_T.CustomerID = Order_T.CustomerID;

A) all rows of the Order_T Table regardless of matches with the Customer_T Table.
B) all rows of the Customer_T Table regardless of matches with the Order_T Table.
C) only rows that match both Customer_T and Order_T Tables.
D) only rows that don't match both Customer_T and Order_T Tables.
Answer: B
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

12) The following code would include:

SELECT Customer_T.CustomerID, Order_T.CustomerID,


CustomerName, OrderID
FROM Customer_T, Order_T
WHERE Customer_T.CustomerID = Order_T. CustomerID;

A) all rows of the Order_T Table regardless of matches with the Customer_T Table.
B) all rows of the Customer_T Table regardless of matches with the Order_T Table.
C) only rows that match both Customer_T and Order_T Tables.
D) only rows that don't match both Customer_T and Order_T Tables.
Answer: C
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

13) A join that is based upon equality between values in two common columns with the same
name and where one duplicate column has been removed is called a(n):
A) equi-join.
B) natural join.
C) multivariate join.
D) inner join.
Answer: B
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

4
Copyright © 2019 Pearson Education, Inc.
14) The most commonly used form of join operation is the:
A) outer join.
B) union join.
C) equi-join.
D) natural join.
Answer: D
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

15) A join in which rows that do not have matching values in common columns are still included
in the result table is called a(n):
A) natural join.
B) equi-join.
C) outer join.
D) union join.
Answer: C
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

16) The outer join syntax does not apply easily to a join condition of more than ________ tables.
A) two
B) three
C) four
D) five
Answer: A
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

17) In which of the following situations would one have to use an outer join in order to obtain
the desired results?
A) A report is desired that lists all customers who placed an order.
B) A report is desired that lists all customers and the total of their orders.
C) A report is desired that lists all customers and the total of their orders during the most recent
month, and includes customers who did not place an order during the month (their total will be
zero).
D) There is never a situation that requires only an outer join.
Answer: C
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Difficult
Classification: Concept
AACSB: Information Technology
5
Copyright © 2019 Pearson Education, Inc.
18) One major advantage of the outer join is that:
A) information is easily accessible.
B) information is not lost.
C) the query is easier to write.
D) information's data type changes.
Answer: B
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

19) An operation to join a table to itself is called a(n):


A) sufficient-join.
B) inner join.
C) outer join.
D) self-join.
Answer: D
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

20) A type of join between three tables is called a(n):


A) ternary join.
B) self-join.
C) unnatural join.
D) pinned join.
Answer: A
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

21) A type of query that is placed within a WHERE or HAVING clause of another query is called
a:
A) master query.
B) subquery.
C) superquery.
D) multi-query.
Answer: B
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

6
Copyright © 2019 Pearson Education, Inc.
22) SQL provides the ________ technique, which involves placing an inner query within the
WHERE or HAVING clause of an outer query.
A) grouping
B) joining
C) subquery
D) union
Answer: C
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

23) ________ takes a value of TRUE if a subquery returns an intermediate results table which
contains one or more rows.
A) IN
B) HAVING
C) EXISTS
D) EXTENTS
Answer: C
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

24) EXISTS will take a value of ________ if the subquery returns an intermediate results table
which contains one or more rows.
A) false
B) 1
C) true
D) undefined
Answer: C
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

25) In SQL, a(n) ________ subquery is a type of subquery in which processing the inner query
depends on data from the outer query.
A) correlated
B) paired
C) natural
D) inner
Answer: A
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology
7
Copyright © 2019 Pearson Education, Inc.
26) ________ use the result of the inner query to determine the processing of the outer query.
A) Correlated subqueries
B) Outer subqueries
C) Inner subqueries
D) Subqueries
Answer: D
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

27) The following code is an example of a:

SELECT CustomerName, CustomerAddress, CustomerCity, CustomerState,


CustomerPostalCode
FROM Customer_T
WHERE Customer_T.CustomerID =
(SELECT Order_T.CustomerID
FROM Order_T
WHERE OrderID = 1008);

A) correlated subquery.
B) subquery.
C) join.
D) FULL OUTER JOIN.
Answer: B
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

28) A materialized view is/are:


A) a virtual table created dynamically on request by a user.
B) an in-line query.
C) copies or replica of data based on queries.
D) always an exact copy of the source table.
Answer: C
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

8
Copyright © 2019 Pearson Education, Inc.
29) When a user creates a virtual table it is called a(n):
A) materialized view.
B) virtual table.
C) inline view.
D) dynamic view.
Answer: D
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

30) What would the following view contain for values?

Create view CustomerOrders as


Select CustID, Count(*) as TotOrders, Sum(ordertotal) as Value
From customer inner join sale on customer.customer_id = sale.customer_id;

A) A listing of all customers in the customer table


B) A listing of the customer ID as well as the total number of orders and the total amount spent
by the customer
C) A listing of the customer ID as well as the total orders
D) An error message
Answer: B
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

31) A named set of SQL statements that are considered when a data modification occurs are
called:
A) stored procedures.
B) treatments.
C) triggers.
D) trapdoors.
Answer: C
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

9
Copyright © 2019 Pearson Education, Inc.
32) All of the following are part of the coding structure for triggers EXCEPT:
A) event.
B) condition.
C) selection.
D) action.
Answer: C
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

33) While triggers run automatically, ________ do not and have to be called.
A) trapdoors
B) routines
C) selects
D) updates
Answer: B
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

34) SQL-invoked routines can be:


A) part of a DDL statement.
B) functions or procedures.
C) part of a DCL statement.
D) contained within a CREATE statement.
Answer: B
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

35) All of the following are advantages of SQL-invoked routines EXCEPT:


A) flexibility.
B) efficiency.
C) sharability.
D) security.
Answer: D
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

10
Copyright © 2019 Pearson Education, Inc.
36) A procedure is:
A) stored outside the database.
B) given a reserved SQL name.
C) called by name.
D) unable to be modified.
Answer: C
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

37) User-defined data types:


A) are not allowed in any DBMS.
B) are only allowed in Oracle.
C) can have defined functions and methods.
D) can be used once in a system.
Answer: C
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

38) A new set of analytical functions added in SQL:2008 is referred to as:


A) OLAF functions.
B) MOLAP functions.
C) average functions.
D) OLAP functions.
Answer: D
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

39) The MERGE command:


A) allows one to combine the INSERT and UPDATE operations.
B) allows one to combine the INSERT and DELETE operations.
C) joins 2 tables together.
D) is always a single table operation.
Answer: A
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

11
Copyright © 2019 Pearson Education, Inc.
40) The ________ DBA view shows information about all users of the database in Oracle.
A) DBA_USERS
B) USERS
C) DBA_VIEWS
D) DBA_INDEXES
Answer: A
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

41) If the DBA wishes to describe all tables in the database, which data dictionary view should
be accessed in Oracle?
A) DBA_TAB_PRIVS
B) DBA_TAB_COMMENTS
C) DBA_TABLE_LABEL
D) DBA_TABLES
Answer: D
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

42) The following statement is an example of:

CREATE TABLE Customer_t (


CustNmbr number(11,0),
CreditLimit number(6,2),
CustStart date,
CustEnd date,
PERIOD for Custperiod(CustStart,CustEnd));

A) a materialized view.
B) an application time period table.
C) a system-versioned table.
D) a dynamic view.
Answer: B
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

12
Copyright © 2019 Pearson Education, Inc.
43) The UNION clause is used to combine the output from multiple queries into a single result
table.
Answer: TRUE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

44) IF-THEN-ELSE logical processing cannot be accomplished within an SQL statement.


Answer: FALSE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

45) Figuring out what attributes you want in your query before you write the query will help with
query writing.
Answer: TRUE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

46) It is better not to have a result set identified before writing GROUP BY and HAVING clauses
for a query.
Answer: FALSE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

47) Specifying the attribute names in the SELECT statement will make it easier to find errors in
queries and also correct for problems that may occur in the base system.
Answer: FALSE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

48) Combining a table with itself results in a faster query.


Answer: FALSE
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

13
Copyright © 2019 Pearson Education, Inc.
49) An equi-join is a join in which one of the duplicate columns is eliminated in the result table.
Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

50) A join in which the joining condition is based on equality between values in the common
column is called an equi-join.
Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

51) The joining condition of an equi-join is based upon an equality.


Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

52) A natural join is the same as an equi-join, except that it is performed over matching columns
that have been defined with the same name, and one of the duplicate columns is eliminated.
Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

53) The natural join is very rarely used.


Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

54) An SQL query that implements an outer join will return rows that do not have matching
values in common columns.
Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

14
Copyright © 2019 Pearson Education, Inc.
55) Using an outer join produces this information: rows that do not have matching values in
common columns are not included in the result table.
Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

56) One major disadvantage of the outer join is that information is easily lost.
Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

57) There is a special operation in SQL to join a table to itself.


Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Difficult
Classification: Concept
AACSB: Information Technology

58) The following code is an example of a Subquery.

SELECT Customer_T.CustomerID, Order_T.CustomerID,


CustomerName, OrderID
FROM Customer_T, Order_T
WHERE Customer_T.CustomerID = Order_T. CustomerID;
Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

59) Joining tables or using a subquery may produce the same result.
Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

15
Copyright © 2019 Pearson Education, Inc.
60) The following queries produce the same results.

SELECT DISTINCT Customer_Name, Customer_City


FROM Customer, Salesman
WHERE Customer.Salesman_ID = Salesman.Salesman_ID
and Salesman.Lname = 'SMITH';

SELECT Customer_Name, Customer_City


FROM Customer
WHERE Customer.Salesman_ID =
(SELECT Salesman_ID
FROM Salesman
WHERE Lname = 'SMITH');
Answer: TRUE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

61) The following query will execute without errors.

SELECT Customer.Customer_Name, Salesman.Sales_Quota


FROM Customer
WHERE Customer.Salesman_ID =
(SELECT Salesman_ID
WHERE Lname = 'SMITH');
Answer: FALSE
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

62) In order to find out what customers have not placed an order for a particular item, one might
use the NOT qualifier along with the IN qualifier.
Answer: TRUE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

63) EXISTS takes a value of false if the subquery returns an intermediate result set.
Answer: FALSE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

16
Copyright © 2019 Pearson Education, Inc.
64) When EXISTS or NOT EXISTS is used in a subquery, the select list of the subquery will
usually just select all columns as a placeholder because it doesn't matter which columns are
returned.
Answer: TRUE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

65) A subquery in which processing the inner query depends on data from the outer query is
called a codependent query.
Answer: FALSE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

66) The following SQL statement is an example of a correlated subquery.

SELECT First_Name, Last_Name, Total_Sales


FROM Salesman s1
WHERE Total_Sales > all
(SELECT Total_Sales FROM Salesman s2
WHERE s1.Salesman_ID != s2.Salesman_ID);
Answer: TRUE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Difficult
Classification: Concept
AACSB: Information Technology

67) A correlated subquery is executed once for each iteration through the outer loop.
Answer: TRUE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

68) Subqueries can only be used in the WHERE clause.


Answer: FALSE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

17
Copyright © 2019 Pearson Education, Inc.
69) Correlated subqueries are less efficient than queries that do not use nesting.
Answer: TRUE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

70) When a subquery is used in the FROM clause, it is called a denied table.
Answer: FALSE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

71) The following code is an example of a correlated subquery.

SELECT CustomerName, CustomerAddress, CustomerCity, CustomerState,


CustomerPostalCode
FROM Customer_T
WHERE Customer_T.CustomerID =
(SELECT Order_T.CustomerID
FROM Order_T
WHERE OrderID = 1008);
Answer: FALSE
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Application
AACSB: Information Technology

72) A materialized view is not persistent.


Answer: TRUE
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

73) A base table is the underlying table that is used to create views.
Answer: TRUE
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

18
Copyright © 2019 Pearson Education, Inc.
74) A dynamic query is created by the user.
Answer: TRUE
LO: 6.5: Write queries to create dynamic and materialized views.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

75) A routine is a named set of SQL statements that are considered when a data modification
occurs.
Answer: FALSE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

76) Constraints are a special case of triggers.


Answer: TRUE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

77) Triggers can be used to ensure referential integrity, enforce business rules, create audit trails,
and replicate tables, but cannot call other triggers.
Answer: FALSE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

78) Triggers have three parts: the event, the condition, and the action.
Answer: TRUE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

79) A function has only input parameters but can return multiple values.
Answer: FALSE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

19
Copyright © 2019 Pearson Education, Inc.
80) The advantages of SQL-invoked routines are flexibility, efficiency, sharability, and
applicability.
Answer: TRUE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

81) A procedure is run by calling it by its name.


Answer: TRUE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

82) A trigger is a named set of SQL statements that are considered when a data modification
occurs.
Answer: TRUE
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

83) SQL allows one to calculate linear regressions, moving averages, and correlations without
moving the data outside of the database.
Answer: TRUE
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Easy
Classification: Concept
AACSB: Information Technology

84) MULTISET is similar to the table datatype.


Answer: FALSE
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

20
Copyright © 2019 Pearson Education, Inc.
85) Establishing IF-THEN-ELSE logical processing within an SQL statement can now be
accomplished by using the CASE keyword in a statement.
Answer: TRUE
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

86) User-defined functions can improve system performance because they will be processed as
sets rather than individually, thus reducing system overhead.
Answer: FALSE
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Concept
AACSB: Information Technology

87) What is a derived table? When is it used? Can you describe any situations where you would
have to use it over a subquery in the WHERE clause?
Answer: A derived table can be created by placing a subquery within the FROM clause. The
derived table is simply a temporary table in memory which can be accessed just like a table or
view. Sometimes, these are referred to as inline views. A derived table is useful for situations
where you need to create aggregate values (such as a sum) and then use these in another query. A
derived table would be used instead of a subquery in cases where you need to display results
from multiple tables. If the results need to come from a subselect, this is not possible, so we
would have to use a derived table.
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

88) Explain how to combine queries using the UNION clause.


Answer: The UNION clause is used to combine the output of multiple queries into one set of
output. In order for the union to work, each query must return the same number of columns.
Also, each output column must be union compatible, meaning it is of the same type. The CAST
command can be used to convert from one datatype to another if need be. If you wish to order
the output rows, you must specify an ORDER BY clause in the last query.
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

21
Copyright © 2019 Pearson Education, Inc.
89) What are some tips for developing queries?
Answer: Some suggestions to help the query writing process include: gaining familiarity with
the data model, entity, and attributes that you are querying. It is also very important to think
about the results that you wish to obtain from the query. Related to this, figure out what attributes
you want the query to return. Once this is done, figure out which tables contain the attributes and
include these in the FROM clause. By reviewing the ERD, you can determine which columns in
each table will be used to establish relationships and establish a link in the WHERE clause. Once
everything works fine, then you can look at the use of GROUP BY and HAVING.
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

90) What strategies can be used to write queries that run more efficiently?
Answer: It makes sense to specify the attribute names rather than just * in the SELECT clause.
If you are writing a query for a wide table, specifying only the attributes that are needed is going
to save a great deal of processing time. Also, changes in the base table post-production could
affect query results. Specifying the attribute names will make it easier to notice and correct for
such errors. Use subqueries sparingly, since these increase processing time. If you have several
separate reports which need data from one table, write one query to retrieve all of the data and
use what you need in each report.
LO: 6.2: Write single- and multiple-table queries using SQL commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

91) Discuss the differences between an equi-join, natural join, and outer join.
Answer: Both a natural join and an equi-join create a join based upon equality between some
common columns. While the equi-join keeps the redundant columns that are used for the match,
the natural join removes duplicates. There are situations where one table may contain
information that is not in the other table. However, it is necessary to display both matching data
as well as records which do not have a match in the second table. This situation is where we
would use an outer join.
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

22
Copyright © 2019 Pearson Education, Inc.
92) What is a self-join and how is it used?
Answer: A self-join is a join of one table to itself. This is often used for unary relationships
where you have a recursive foreign key. One possible use for this would be to produce a list of
who is supervised by another staff member. Self-joins can be slow, so they should be used with
caution.
LO: 6.3: Define three types of join commands and use SQL to write these commands.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

93) When is it better to use a subquery over using a join?


Answer: Often, a subquery and join will return the same results. Joining is most useful when
data from several tables needs to be retrieved and there is no nesting. When relationships are
nested, it is best to use a subquery. Also, some queries (such as some not in queries) could not be
done with joins.
LO: 6.4: Write noncorrelated and correlated subqueries and know when to write each.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

94) What is the difference between a trigger and a routine?


Answer: A trigger, once written and compiled, sits silently on the database server waiting for an
event to happen. It is usually tied to one table and some action, such as insert, update, or delete.
Conversely, a routine has to be called even though it resides on the database server. It may access
one, many, or no tables in order to produce the desired results.
LO: 6.6: Understand common uses of database triggers and stored procedures.
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

95) Discuss some of the SQL:2011 and SQL:2016 enhancements and extensions to SQL.
Answer: Several built-in functions were added in SQL:2011 and SQL:2016. These include
ceiling, floor, SQRT, rank, dense_rank, rollup, cube, sample, and window. Many operations, such
as OLAP operations, can be done within the SQL SELECT statement. There were also three new
data types: BIGINT, MULTISET and XML. In addition, the merge operation was added.
LO: 6.7: Discuss the SQL:2011 and SQL:2016 standards and explain SQL enhancements and
extensions
Difficulty: Moderate
Classification: Synthesis
AACSB: Information Technology

23
Copyright © 2019 Pearson Education, Inc.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy