• Non ci sono risultati.

Politecnico di Torino Database Management Systems

N/A
N/A
Protected

Academic year: 2021

Condividi "Politecnico di Torino Database Management Systems"

Copied!
3
0
0

Testo completo

(1)

Politecnico di Torino

Database Management Systems

September 21

st

2011

1. (6 Points) The following relations are given (primary keys are underlined):

PLAY-ACTOR(AId, Name, Nationality, BirthDate) COMEDY(ComId, Title, Director, SceneNumber, Year) PLAY-ACTOR-IN-COMEDY(ComId, AId, Role)

PLANNING(ComId, Theater, Date, StartTime, LengthOfTime) Assume the following cardinalities:

• card(PLAY-ACTOR)= 104 tuples,

MIN(BirthDate) = 1-1-1960, MAX(BirthDate) = 31-12-1999,

• card(COMEDY)= 103 tuples,

distinct values of SceneNumber ≃15,

• card(PLAY-ACTOR-IN-COMEDY)= 106 tuples, distinct values of Role ≃30,

• card(PLANNING)= 108 tuples,

MIN(Date) = 1-1-2010, MAX(Date) = 31-12-2010, MIN(LengthOfTime) = 81, MAX(LengthOfTime) = 180,

Furthermore, assume the following reduction factor for the group by condition:

• having count(DISTINCT Theater)≥50 ≃ 101 . Consider the following SQL query:

select Title, Director

from COMEDY C, PLANNING P, PLAY-ACTOR-IN-COMEDY AC where P.ComId=C.ComId and AC.ComId=C.ComId

and LengthOfTime=180 and SceneNumber>12 and AC.Aid in (select Aid from PLAY-ACTOR

where BirthDate ≥ 1996) group by ComId, Title, Director

having count(DISTINCT Theater) ≥ 50 For the SQL query:

(a) Report the corresponding algebraic expression and specify the cardinality of each node (repre- senting an intermediate result or a leaf). If necessary, assume a data distribution. Also analyze the group by anticipation.

(b) Select one or more secondary physical structures to increase query performance. Justify your choice and report the corresponding execution plan (join orders, access methods, etc.).

Join and group by discussion:

(1) Nested loop (2) Hash Join

(3) Hash Join or Nested loop (4) GB Hash

Indexes:

(2)

• Table PLANNING: B+-Tree on LengthOfTime

• Table PLAY-ACTOR: B+-Tree on BirthDate Group by anticipation:

Pay attention: The distinct statement should be insert into the select clause since a many-to-many relationship holds among comedy and actor tables.

Join and group by discussion:

(1) Nested loop (2) Nested loop

(3) Hash Join or Nested loop (4) GB Hash

2

(3)

3

Riferimenti

Documenti correlati

A leave request is accepted if the person requesting it is not on duty in the requested date (SHIFT table). If instead the person is on duty, the request is accepted only if

The calculation of a new pay-packet is requested (a new record is inserted in the PAY PACKET REQUEST table), for the hours of work of a given employee in a specific month.. To

(c) For each spare part of cars manufactured by FIAT and considering only the turnover of the European agencies in 2011, for each city where an agency is located, select the

If the number of available packages is greater than the number of requested packages, you must enter the requested drug in the shopping cart (table CONTENTS OF SHOPPING CART)..

(b) Considering only the airports located in Europe, for each city of departure located in Italy, for each city of arrival and for each month, select the daily average total income,

(c) Select the total number of newly registered users for each day of the week and the percentage of newly registered users for each day of the week respect with the total number

(b) For each team and month, select the average number of code rows which have been added by each commit operation, separately for each combination of commit types (bugfix, etc.).

(a) Select the percentage of males and the percentage of females with respect to the total number of recognized people (children included), separately for each day of the week