Exam 9: Advanced Query Formulation With SQL

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

A good table design usually eliminates the use of null values,so their effects on query results is not generally a concern for database developers.

Free
(True/False)
4.8/5
(30)
Correct Answer:
Verified

False

An operator that generates a result table that contains the matching rows of both tables plus the non-matching rows of both of the input tables is a(n)_____________________.

Free
(Short Answer)
4.8/5
(35)
Correct Answer:
Verified

full outer join

Figuer: CUSTOMER CID CNAME AGE RESID\_CITY BIRTHPLACE 10 BLACK 40 ERIE TAMPA 20 GREEN 25 CARY ERIE 30 JONES 30 HEMET TAMPA 40 MARTIN 35 HEMET TAMPA 50 SIMON 22 ERIE ERIE 60 VERNON 60 CARY CARY In table CUSTOMER, CID is the primary key (Customer ID). RENTALS CID MAKE DATE\_OUT PICKUP RETURN RTN 10 FORD 10-0ct-1994 CARY CARY 1 10 GM 01-Nov-1995 TAMPA CARY 2 10 FORD 01-Jan-1995 ERIE ERIE 3 20 NISSAN 07-Ju1-1994 TAMPA TAMPA 4 30 FORD 01-Jul-1995 CARY ERIE 5 30 GM 01-Aug-1995 ERIE ERIE 6 40 FORD 01-Aug-1994 CARY ERIE 7 50 GM 01-Sep-1995 ERIE CARY 8 70 TOYOTA 02-Sep-1995 RENO RENO 9 In the table RENTALS, RTN provides the rental number (the primary key), CID is the customer's unique id, PICKUP is the city where the car was picked up, and Return is the city where the car was returned. RENTCOST MAKE COST FORD 30 GM 40 NISSAN 30 TOYOTA 20 VOLVO 50 RENTCOST shows the base cost of renting a given MAKE for one day. CITYADJ CITY FACTOR CARY 1 ERIE 1.1 RENO 0.9 TAMPA 0.8 If the return city of table RENTALS is the one listed in table CITYADJ, the cost of the rental is multiplied by FACTOR and by DAYS shown in table RENTLENGTH below. RENTLENGTH RTN DAYS 1 1 2 3 3 2 4 2 5 4 6 2 7 3 8 1 RENTLENGTH shows the number of days for the rental number (RTN) shown in table RENTALS. In a database used in reality, this table would be merged with the RENTALS table. -SELECT MAKE FROM RENTALS,CUSTOMER WHERE RENTALS.CID = CUSTOMER.CID AND RESID_CITY = 'HEMET ' GROUP BY MAKE HAVING COUNT (DISTINCT RENTALS.CID)= (SELECT COUNT(*)FROM CUSTOMER WHERE RESID_CITY = 'HEMET') The meaning of this query is the following:

Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
Verified

C

The following two functions will always produce the same value when performed in a SQL statement: SUM(Column1)+ SUM(Column2) SUM(Column1 + Column2)

(True/False)
4.8/5
(36)

A(n)_______________ nested query executes one time for each row in the outer query.

(Short Answer)
4.8/5
(34)

Figuer: VOTE Name votel vote2 Bill 20 15 Mary 10 25 Jill 15 0 Bob 30 -SELECT * FROM VOTE WHERE Vote2 >=10 The execution of this query produces the following number of rows:

(Multiple Choice)
4.8/5
(41)

When performing a grouping operation,the SQL standard specifies that all rows with null values are grouped together.

(True/False)
4.8/5
(35)

Type I nested queries can be used like loops and Type II nested queries can be used like procedures in a programming language.

(True/False)
4.9/5
(39)

In a difference problem using a Type II nested query,a NOT EXISTS condition in a WHERE clause would evaluate to ________ if the nested query returned zero rows.

(True/False)
4.8/5
(40)

Figuer: CUSTOMER CID CNAME AGE RESID\_CITY BIRTHPLACE 10 BLACK 40 ERIE TAMPA 20 GREEN 25 CARY ERIE 30 JONES 30 HEMET TAMPA 40 MARTIN 35 HEMET TAMPA 50 SIMON 22 ERIE ERIE 60 VERNON 60 CARY CARY In table CUSTOMER, CID is the primary key (Customer ID). RENTALS CID MAKE DATE\_OUT PICKUP RETURN RTN 10 FORD 10-0ct-1994 CARY CARY 1 10 GM 01-Nov-1995 TAMPA CARY 2 10 FORD 01-Jan-1995 ERIE ERIE 3 20 NISSAN 07-Ju1-1994 TAMPA TAMPA 4 30 FORD 01-Jul-1995 CARY ERIE 5 30 GM 01-Aug-1995 ERIE ERIE 6 40 FORD 01-Aug-1994 CARY ERIE 7 50 GM 01-Sep-1995 ERIE CARY 8 70 TOYOTA 02-Sep-1995 RENO RENO 9 In the table RENTALS, RTN provides the rental number (the primary key), CID is the customer's unique id, PICKUP is the city where the car was picked up, and Return is the city where the car was returned. RENTCOST MAKE COST FORD 30 GM 40 NISSAN 30 TOYOTA 20 VOLVO 50 RENTCOST shows the base cost of renting a given MAKE for one day. CITYADJ CITY FACTOR CARY 1 ERIE 1.1 RENO 0.9 TAMPA 0.8 If the return city of table RENTALS is the one listed in table CITYADJ, the cost of the rental is multiplied by FACTOR and by DAYS shown in table RENTLENGTH below. RENTLENGTH RTN DAYS 1 1 2 3 3 2 4 2 5 4 6 2 7 3 8 1 RENTLENGTH shows the number of days for the rental number (RTN) shown in table RENTALS. In a database used in reality, this table would be merged with the RENTALS table. -(ACCESS)SELECT CNAME,DATE_OUT FROM CUSTOMER INNER JOIN RENTALS ON CUSTOMER.CID = RENTALS.CID WHERE AGE < 40 AND RTN IN (SELECT RTN FROM RENTLENGTH WHERE DAYS > 1) The CNAMEs shown by the execution of this query are:

(Multiple Choice)
4.8/5
(29)

Figuer: CUSTOMER CID CNAME AGE RESID\_CITY BIRTHPLACE 10 BLACK 40 ERIE TAMPA 20 GREEN 25 CARY ERIE 30 JONES 30 HEMET TAMPA 40 MARTIN 35 HEMET TAMPA 50 SIMON 22 ERIE ERIE 60 VERNON 60 CARY CARY In table CUSTOMER, CID is the primary key (Customer ID). RENTALS CID MAKE DATE\_OUT PICKUP RETURN RTN 10 FORD 10-0ct-1994 CARY CARY 1 10 GM 01-Nov-1995 TAMPA CARY 2 10 FORD 01-Jan-1995 ERIE ERIE 3 20 NISSAN 07-Ju1-1994 TAMPA TAMPA 4 30 FORD 01-Jul-1995 CARY ERIE 5 30 GM 01-Aug-1995 ERIE ERIE 6 40 FORD 01-Aug-1994 CARY ERIE 7 50 GM 01-Sep-1995 ERIE CARY 8 70 TOYOTA 02-Sep-1995 RENO RENO 9 In the table RENTALS, RTN provides the rental number (the primary key), CID is the customer's unique id, PICKUP is the city where the car was picked up, and Return is the city where the car was returned. RENTCOST MAKE COST FORD 30 GM 40 NISSAN 30 TOYOTA 20 VOLVO 50 RENTCOST shows the base cost of renting a given MAKE for one day. CITYADJ CITY FACTOR CARY 1 ERIE 1.1 RENO 0.9 TAMPA 0.8 If the return city of table RENTALS is the one listed in table CITYADJ, the cost of the rental is multiplied by FACTOR and by DAYS shown in table RENTLENGTH below. RENTLENGTH RTN DAYS 1 1 2 3 3 2 4 2 5 4 6 2 7 3 8 1 RENTLENGTH shows the number of days for the rental number (RTN) shown in table RENTALS. In a database used in reality, this table would be merged with the RENTALS table. -SELECT CID FROM RENTALS GROUP BY CID HAVING COUNT (DISTINCT MAKE)= (SELECT COUNT(*)FROM RENTCOST) The operation performed by this query is:

(Multiple Choice)
4.9/5
(29)

Nested queries can be used like a procedure (Type I nested query)in which the nested query is executed one time or like a loop (Type II nested query)in which the nested query is executed repeatedly.

(Multiple Choice)
4.9/5
(27)

Figuer: CUSTOMER CID CNAME AGE RESID\_CITY BIRTHPLACE 10 BLACK 40 ERIE TAMPA 20 GREEN 25 CARY ERIE 30 JONES 30 HEMET TAMPA 40 MARTIN 35 HEMET TAMPA 50 SIMON 22 ERIE ERIE 60 VERNON 60 CARY CARY In table CUSTOMER, CID is the primary key (Customer ID). RENTALS CID MAKE DATE\_OUT PICKUP RETURN RTN 10 FORD 10-0ct-1994 CARY CARY 1 10 GM 01-Nov-1995 TAMPA CARY 2 10 FORD 01-Jan-1995 ERIE ERIE 3 20 NISSAN 07-Ju1-1994 TAMPA TAMPA 4 30 FORD 01-Jul-1995 CARY ERIE 5 30 GM 01-Aug-1995 ERIE ERIE 6 40 FORD 01-Aug-1994 CARY ERIE 7 50 GM 01-Sep-1995 ERIE CARY 8 70 TOYOTA 02-Sep-1995 RENO RENO 9 In the table RENTALS, RTN provides the rental number (the primary key), CID is the customer's unique id, PICKUP is the city where the car was picked up, and Return is the city where the car was returned. RENTCOST MAKE COST FORD 30 GM 40 NISSAN 30 TOYOTA 20 VOLVO 50 RENTCOST shows the base cost of renting a given MAKE for one day. CITYADJ CITY FACTOR CARY 1 ERIE 1.1 RENO 0.9 TAMPA 0.8 If the return city of table RENTALS is the one listed in table CITYADJ, the cost of the rental is multiplied by FACTOR and by DAYS shown in table RENTLENGTH below. RENTLENGTH RTN DAYS 1 1 2 3 3 2 4 2 5 4 6 2 7 3 8 1 RENTLENGTH shows the number of days for the rental number (RTN) shown in table RENTALS. In a database used in reality, this table would be merged with the RENTALS table. -DELETE FROM CUSTOMER WHERE CID IN (SELECT CID FROM RENTALS WHERE RETURN IN (SELECT BIRTHPLACE FROM CUSTOMER)) The number of rows deleted from CUSTOMER by the execution of this query is:

(Multiple Choice)
4.8/5
(32)

Nested queries can be used as part of a condition in WHERE or HAVING clauses,but they cannot be used in the FROM clause of a query.

(True/False)
4.9/5
(32)

When using the SUM function with two columns,a row containing a null value for either column would produce a null value for that row.

(True/False)
4.9/5
(30)

A nested query in which the inner query does not reference any tables in the outer query is a(n)__________________.

(Short Answer)
4.9/5
(41)

A nested query cannot have multiple levels,i.e.you cannot have a nested query inside another nested query.

(True/False)
4.7/5
(37)

Figuer: CUSTOMER CID CNAME AGE RESID\_CITY BIRTHPLACE 10 BLACK 40 ERIE TAMPA 20 GREEN 25 CARY ERIE 30 JONES 30 HEMET TAMPA 40 MARTIN 35 HEMET TAMPA 50 SIMON 22 ERIE ERIE 60 VERNON 60 CARY CARY In table CUSTOMER, CID is the primary key (Customer ID). RENTALS CID MAKE DATE\_OUT PICKUP RETURN RTN 10 FORD 10-0ct-1994 CARY CARY 1 10 GM 01-Nov-1995 TAMPA CARY 2 10 FORD 01-Jan-1995 ERIE ERIE 3 20 NISSAN 07-Ju1-1994 TAMPA TAMPA 4 30 FORD 01-Jul-1995 CARY ERIE 5 30 GM 01-Aug-1995 ERIE ERIE 6 40 FORD 01-Aug-1994 CARY ERIE 7 50 GM 01-Sep-1995 ERIE CARY 8 70 TOYOTA 02-Sep-1995 RENO RENO 9 In the table RENTALS, RTN provides the rental number (the primary key), CID is the customer's unique id, PICKUP is the city where the car was picked up, and Return is the city where the car was returned. RENTCOST MAKE COST FORD 30 GM 40 NISSAN 30 TOYOTA 20 VOLVO 50 RENTCOST shows the base cost of renting a given MAKE for one day. CITYADJ CITY FACTOR CARY 1 ERIE 1.1 RENO 0.9 TAMPA 0.8 If the return city of table RENTALS is the one listed in table CITYADJ, the cost of the rental is multiplied by FACTOR and by DAYS shown in table RENTLENGTH below. RENTLENGTH RTN DAYS 1 1 2 3 3 2 4 2 5 4 6 2 7 3 8 1 RENTLENGTH shows the number of days for the rental number (RTN) shown in table RENTALS. In a database used in reality, this table would be merged with the RENTALS table. -SELECT DISTINCT CID,CNAME FROM CUSTOMER WHERE CID IN (SELECT CID FROM RENTALS WHERE MAKE IN ('FORD','TOYOTA') AND RTN IN (SELECT RTN FROM RENTLENGTH WHERE DAYS < 3)) The CNAMEs shown by the execution of this query are:

(Multiple Choice)
4.8/5
(33)

Select the statement that is correct about the outer join operator:

(Multiple Choice)
4.8/5
(37)

In Access,a nested query in the FROM clause would be used to overcome the inability of using the keyword ____________ inside aggregate functions.

(Short Answer)
4.8/5
(39)
Showing 1 - 20 of 74
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)