• Non ci sono risultati.

Databases DBDMG - Politecnico di Torino Relational Algebra (I) – Solutions

N/A
N/A
Protected

Academic year: 2021

Condividi "Databases DBDMG - Politecnico di Torino Relational Algebra (I) – Solutions"

Copied!
12
0
0

Testo completo

(1)

DBDMG - Politecnico di Torino Relational Algebra (I) – Solutions

Exercise 1. Given the relational schema including the following tables (primary keys are underlined):

MAGAZINE (MId, MName, Publisher) ARTICLE (AId, Title, Topic, MId) express the following queries in relational algebra:

(a) Find the names of the magazines that have published at least one article about motorcycles.

(b) Find the names of the magazines that have never published any article about motorcycles.

(2)

Alternative solution:

(c) Find the names of the magazines that have only ever published articles about motorcycles.

Alternative solution:

(3)

Alternative solution:

(d) Find the names of the magazines that publish articles about motorcycles or cars.

(e) Find the names of the magazines that publish both articles about motorcycles and articles about cars.

(4)

Alternative solution:

Alternative solution:

(f) Find the names of the magazines that have published at least two articles about motorcycles.

(5)

(g) Find the names of the magazines that have published only one article about motorcycles (i.e., they may have published any number of articles about other topics).

Alternative solution:

(6)

Alternative solution:

Exercise 2. Given the relational schema including the following tables (primary keys are underlined):

SAILOR(SId, SName, Expertise, DateOfBirth) BOOKING(SId, BId, Date)

BOAT(BId, BName, Color) express the following queries in relational algebra:

(a) Find the names of the sailors who have booked a red boat or a green boat.

(b) Find the codes and the names of the sailors who have booked a red boat and a green boat.

(7)

Alternative solution:

Alternative solution:

(c) Find the codes of the sailors who have never booked a red boat.

(8)

Alternative solution:

(9)

(d) Find the codes and the names of the sailors who have never booked a red boat.

Alternative solution:

(e) Find the codes and the names of the sailors who have booked at least two boats.

(10)

(f) Find the codes and the names of the sailors who have booked at least three boats.

(11)

Exercise 3. Given the relational schema including the following tables (primary keys are underlined):

AIRCRAFT(AId, AName, MaximumRange) CERTIFICATE(PId, AId)

PILOT(PId, PName, Salary) express the following queries in relational algebra:

(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 the names of the pilots who are qualified to fly on at least two aircrafts that can cover distances greater than 5,000 km.

(12)

(c) Find the codes and the names of the pilots who are qualified to fly on at least two aircrafts that can cover distances greater than 5,000 km, and who are qualified to fly on a Boeing.

Alternative solution:

Riferimenti

Documenti correlati

[r]

b Verify it satisfies the Kolmogorov forward

Solution proposed by Roberto Tauraso, Dipartimento di Matematica, Universit`a di Roma “Tor Vergata”, via della Ricerca Scientifica, 00133 Roma, Italy.. Let a n,k be the number

To drill a cube is to partition it into 27 congruent subcubes and remove the closed central cube along with the 6 remaining subcubes sharing a face with that cube, resulting in a

[r]

Answer: As a basis of Im A, take the first, fourth and fifth columns, so that A has rank 3. Find a basis of the kernel of A and show that it really is a basis... Does the union of

If S is not a linearly independent set of vectors, remove as many vectors as necessary to find a basis of its linear span and write the remaining vectors in S as a linear combination

To receive full credit, show all of your work.. Neither calculators nor computers