Exam 4: Relational Data Retrieval: SQL

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

The SQL SELECT command is used to ____ a relational database.

Free
(Multiple Choice)
4.9/5
(28)
Correct Answer:
Verified

A

The SQL SELECT ORDER BY operator ____.

Free
(Multiple Choice)
4.9/5
(36)
Correct Answer:
Verified

E

Consider the following relational database for Grand Travel Airlines. Grand Travel Airlines has to keep track of its flight and airplane history. A flight is uniquely identified by the combination of a flight number and a date. Every passenger who has flown on Grand Travel has a unique passenger number. For a particular passenger who has taken a particular flight, the company wants to keep track of the fare that she paid for it and the date that she made the reservation for it. Clearly, a passenger may have taken many flights (he must have taken at least one to be in the database) and every flight has had many passengers on it. A pilot is identified by a unique pilot (or employee) number. A flight on a particular date has exactly one pilot. Each pilot has typically flown many flights but a pilot may be new to the company, is in training, and has not flown any flights, yet. Each airplane has a unique serial number. A flight on a particular date used one airplane. Each airplane has flown on many flights and dates, but a new airplane may not have been used at all, yet. PLOTNUM PILOTNAME BIRTHDATE HIREDATE PILOT Relation FLIGHTNUM DATE DEPTIME ARRTIME PLINNUM PLANENUM FLIGHT Relation PASSNUM PASSNAME ADDRESS PHONE PASSENGER Relation FLIGHTNUM DATE PASSNUM FARE RESVDATE RESERVATION Relation PLANENUM MODEL CAPACITY YEARBULL MANUF AIRPLANE Relation Write SQL SELECT commands to answer the following queries. a. Find the records for the airplanes manufactured by Boeing. b. How many reservations are there for flight 278 on February 21, 2004? c. List the flights on March 7, 2004 that are scheduled to depart between 10 and 11AM or that are scheduled to arrive after 3PM on that date. d. How many Boeing 737s does Grand Travel have? e. How many of each model of Boeing aircraft does Grand Travel have? f. List the names and dates of hire of the pilots who flew Airbus A320 aircraft in March, 2004. g. List the names, addresses, and telephone numbers of the passengers who have reservations on Flight 562 on January 15, 2004. h. What was the total fare paid for each flight scheduled to depart between 9 and 10AM on December 23, 2003? Only include those flights for which the total fare was at least $5,000. i. List the smallest (in terms of passenger capacity) Boeing 737s. j. List the Airbus A310s that are larger (in terms of passenger capacity) than the smallest Boeing 737s.

Free
(Essay)
4.8/5
(36)
Correct Answer:
Verified

a. SELECT *
FROM AIRPLANE
WHERE MANUF='Boeing';

b. SELECT COUNT(*)
FROM RESERVATION
WHERE FLIGHTNUM=278
AND DATE='FEB-21-2004;

c. SELECT DISTINCT FLIGHTNUM
FROM FLIGHT
WHERE DATE='MAR-07-2004'
AND (DEPTIME BETWEEN 1000 AND 1059
OR ARRTIME>1500);

d. SELECT COUNT(*)
FROM AIRPLANE
WHERE MANUF='Boeing'
AND MODEL='737';

e. SELECT MODEL, COUNT(*)
FROM AIRPLANE
WHERE MANUF='Boeing'
GROUP BY MODEL;

f. SELECT PILOTNAME, HIREDATE
FROM PILOT, FLIGHT, AIRPLANE
WHERE PILOT.PILOTNUM=FLIGHT.PILOTNUM
AND FLIGHT.PLANENUM=AIRPLANE.PLANENUM
AND MANUF='Airbus'
AND MODEL='A320'
AND DATE BETWEEN 'MAR-01-2004' AND 'MAR-31-2004';

g. SELECT PASSNAME, ADDRESS, PHONE
FROM PASSENGER, RESERVATION
WHERE PASSENGER.PASSNUM=RESERVATION.PASSNUM
AND FLIGHTNUM=562
AND DATE='JAN-15-2004';

h. SELECT FLIGHT.FLIGHTNUM, SUM(FARE)
FROM FLIGHT, RESERVATION
WHERE FLIGHT.FLIGHTNUM=RESERVATION.FLIGHTNUM
AND FLIGHT.DATE=RESERVATION.DATE
AND RESERVATION.DATE='DEC-23-2003'
AND DEPTIME BETWEEN 900 AND 1000
GROUP BY FLIGHT.FLIGHTNUM
HAVING SUM(FARE)>=5000;

i. SELECT PLANENUM
FROM AIRPLANE
WHERE MANUF='Boeing'
AND MODEL='737'
AND CAPACITY=
(SELECT MIN(CAPACITY)
FROM AIRPLANE
WHERE MANUF='Boeing'
AND MODEL='737');

j. SELECT PLANENUM
FROM AIRPLANE
WHERE MANUF='Airbus'
AND MODEL='A310'
AND CAPACITY>
(SELECT MIN(CAPACITY)
FROM AIRPLANE
WHERE MANUF='Boeing'
AND MODEL='737');

For the nested-loop join to work, each of the two join attributes either has to be in sorted order or has to have an index built over it.

(True/False)
4.8/5
(38)

In an SQL SELECT command a SELECT clause with several attributes, a FROM clause with multiple tables and a WHERE clause with join fields set equal plus other predicates indicate a(n) ____.

(Multiple Choice)
4.8/5
(38)

Search arguments appear in the SQL SELECT command WHERE clause.

(True/False)
4.7/5
(31)

The HAVING clause limits the results of a GROUP BY clause based on the values calculated for each group with the built-in functions.

(True/False)
4.8/5
(39)

A data manipulation language (DML) is capable of ____.

(Multiple Choice)
4.9/5
(33)

In a merge-scan join ____.

(Multiple Choice)
4.9/5
(30)

A relational DBMS's relational query optimizer obtains the information it needs about the database from the DBMS's relational catalog.

(True/False)
4.9/5
(38)

The SQL SELECT built-in function COUNT ____.

(Multiple Choice)
4.9/5
(34)

In the SQL SELECT command, the table(s) involved in the query is (are) specified in the ____ clause.

(Multiple Choice)
4.9/5
(38)

The built-in function COUNT in an SQL SELECT command adds a specified set of attribute values.

(True/False)
4.7/5
(40)

All of the following are SQL commands, except ____.

(Multiple Choice)
4.9/5
(39)

A relational query optimizer is an expert system within a relational DBMS.

(True/False)
4.7/5
(28)

When a subquery is present in an SQL SELECT statement, the subquery is executed before the main query.

(True/False)
5.0/5
(40)

The SQL SELECT BETWEEN operator is used ____.

(Multiple Choice)
4.8/5
(40)

SQL SELECT commands must be issued against the actual, physical database tables rather than against "logical views" of the tables.

(True/False)
4.8/5
(31)

The SQL SELECT IN operator ____.

(Multiple Choice)
4.7/5
(30)

The tables to be joined in an SQL SELECT statement are listed in the FROM clause.

(True/False)
5.0/5
(38)
Showing 1 - 20 of 71
close modal

Filters

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