• 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!
2
0
0

Testo completo

(1)

Politecnico di Torino

Database Management Systems

July 8

th

2011

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

USER(UId, Name, Surname, City, State, BirthDate) PHOTO(PId, UId, Resolution, KBs)

UPLOAD(PId, Date, Time, Description) TAG(PId, Tag)

Assume the following cardinalities:

• card(USER)= 106 tuples,

MIN(BirthDate) = 1-1-1941, MAX(BirthDate) = 31-12-1990, number of City ≃102,

number of State ≃10,

• card(PHOTO)= 108 tuples, number of Resolution ≃10,

MIN(KBs) = 102, MAX(KBs) = 2 · 103,

• card(UPLOAD)= 5 · 108 tuples,

MIN(Date) = 01-01-2010, MAX(Date) = 31-12-2010,

• card(TAG)= 109 tuples

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

• having count(distinct tag) ≤ 10 ≃ 10099. Consider the following SQL query:

select UId, Name, Surname from USER U, PHOTO P

where U.UId=P.PId and BirthDate > 1-1-1981 and City =’Rome’

and PId NOT IN (select UP.PId

from UPLOAD UP, TAG T, PHOTO P1 where UP.PId=T.PId and UP.PId=P1.PId

and Date ≥ 01-06-2010 and Date ≤ 30/06/2010 and Resolution <> ’1280x720’

group by UP.PId

having count(distinct Tag) ≤10);

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) Hash Join

(2)

(2) Hash Join (3) GB No Hash

(4) Hash Join or Nested loop (5) Hash Join

Indexes:

• Table Upload: B+-Tree on Date

• Table User: Hash on City

2

Riferimenti

Documenti correlati

If the statement accesses only columns of the index, the indexed column values are read directly from the index, otherwise the rows in the table are accessed by means of the rowid.

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,

(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

•I dati sono organizzati in insiemi omogenei ( tabelle in Access), fra i quali sono definite delle relazioni.. •I dati sono molti, in assoluto e rispetto ai metadati, e non