• Non ci sono risultati.

Introduction to Databases Homework n. 2 - SQL

N/A
N/A
Protected

Academic year: 2021

Condividi "Introduction to Databases Homework n. 2 - SQL"

Copied!
1
0
0

Testo completo

(1)

Introduction to Databases Homework n. 2 - SQL

1. Given the following relational schema:

TRAINER (SSN, Name, Surname, City) GYM (CodG, NameP, City, Address) SPECIALTY (CodS, NameS, Description)

GROUP_LESSON (SSN, CodG, Date, CodS, ParticipantsNumber) Write the following queries in SQL language:

a. Show SSN, name and surname of every personal trainer who gave group lessons in at least 3 different gyms located in Turin.

b. For each gym in which more than 10 Karate group lessons (NameS = "Karate") have been conducted, show the code of the gym and, separately for each trainer, the total number of participants to the group lessons (of any specialty) given by the trainer in that gym.

c. For each personal trainer who gave group lessons at every gym in his city, show name, surname and the number of specialties for which he gave lessons.

2. Given the following relational schema:

USER (SSN, NameU, SurnameU, City, YearOfBirth, UserType) MOVIE (CodM, Title, Nation, Language, MovieStudio, Genre) EVALUATION (SSN, CodM, Evaluation, Date)

Write the following queries in SQL language:

a. For each user type, show the average evaluation given to movies produced by

"Marvel" (MovieStudio = "Marvel").

b. For each user belonging to type "Expert" who has never evaluated movies of genre "Horror" but has evaluated at least 3 movies of genre "Comedy", show name, surname and the highest evaluation assigned to movies in language "Italian".

1

Riferimenti

Documenti correlati

35 principi guida configurano la vision della Fondazione GIMBE sulla sanità pubblica e sono stati definiti tenendo conto di: legislazione vigente, contesto politico, economi- co

◼ The study of active database systems and SQL statements for trigger definition. ◼ The development of web-based applications for database querying

Find the names of the suppliers that supply at least one product supplied by suppliers of red products. D B

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). AIRCRAFT (AId,

Find the codes of the sailors who have never booked a red boat SAILOR (SId, SName, Expertise, DateofBirth). BOOKING (SId, BId, Date) BOAT(Bid,

SELECT DISTINCT PersonName FROM LEASING_CONTRACT LC GROUP BY PersonNamem, FCode HAVING COUNT(*)>2.. FLAT (FCode, Address,

• Customer stays on board of a cruise ship are characterized by starting and ending dates, by leaving and arrival cities (docking cities of the cruise ships owned by the company),

[r]