• Non ci sono risultati.

Databases DBDMG - Politecnico di Torino SQL (II)

N/A
N/A
Protected

Academic year: 2021

Condividi "Databases DBDMG - Politecnico di Torino SQL (II)"

Copied!
1
0
0

Testo completo

(1)

Databases

DBDMG - Politecnico di Torino SQL (II)

Exercise 1. Given the following relations (primary keys are underlined):

COURSE (CourseCode, CourseName, Year, Semester)

COURSE SCHEDULE (CourseCode, DayOfWeek, StartTime, EndTime, Room) express the following queries in SQL language:

(a) Find the rooms in which none of the first-year courses has ever been given.

(b) Find the codes, the names and the total number of weekly hours of the third-year courses whose total number of weekly hours is greater than 10 and whose schedule spans three different days of the week.

Exercise 2. Given the following relations (primary keys are underlined):

FLAT (FCode, Address, City, Surface)

LEASING CONTRACT (LCCode, StartDate, EndDate, PersonName, MonthlyPrice, FCode)

N.B. The Surface is expressed in square meters. For contracts that have not yet expired the EndDate is NULL.

express the following queries in SQL language:

(a) For the cities in which at least 100 contracts have been signed, find the city, the maximum monthly price, the average monthly price, the maximum duration of the leasing contracts, the average duration of the leasing contracts and the total number of signed contracts.

(b) Find the names of the people who have never rented any flat with a surface greater than 80 square meters.

(c) Find the names of the people who have signed more than two leasing contracts for the same flat (in different periods).

(d) Find the codes and the addresses of flats in Turin whose monthly leasing price has always been greater than 500AC and for which more than 5 contracts have been signed.

Exercise 3. Given the following relations (primary keys are underlined) PERSON (Name, Sex, Age)

PARENT (ParentName, ChildName)

express the following queries in SQL language:

(a) Find the name of each person younger than 10 years old who is an only child.

1

Riferimenti

Documenti correlati

Government Printing Office , Social Security Administration (US)..

Let us describe here a sample implementation of the algo- rithms outlined in the book. The high-level structure of the source code is an implementation of a Monte Carlo algorithm,

This paper reports an experimental study of transient natural convection heat and mass transfer between two large cylindrical reservoirs connected through a short

[r]

B.4 Post-study questionnaire in Italian language administered after using the remote monitoring service (Part

(a) Find the codes and the names of the pilots who are qualified to fly on an aircraft that can cover distances greater than 5,000 km (MaximumRange ≥ 5,000). (b) Find the codes and

(b) For pharmacies that have sold a total quantity of drugs greater than the average quantity of drugs sold by all pharmacies, show the pharmacy code, the name of the owner, and

Given the following relations (primary keys are underlined) BEACH (BeachAddress, BeachCity, Capacity, LifeguardInCharge) LIFEGUARD (LID, FirstName, LastName, HomeCity,