HW 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Exercise 1 (6 points)

Let 𝑅 and 𝑆 be the following tables:

𝑅 𝑆
A B C D
3 0 2 3
0 2 1 1
3 5 1 2
A C E
1 3 0
3 2 3
1 0 3
3 2 2
3 1 0

Give the tables produced by the following relational algebra queries (1 pt for each correct answer):

(
1. Π𝐵, 𝐷 σ𝐴 ≥ 1(𝑅) )
(
2. Π𝐶 σ𝐴≠3 𝑜𝑟 𝐸=2 (𝑆) )
3. Π𝐴, 𝐶 (𝑅)∪ Π𝐴, 𝐶 (𝑆)
4. Π𝐴, 𝐶 (𝑅)∩ Π𝐴, 𝐶 (𝑆)
5. Π𝐴, 𝐶 (𝑅) − Π𝐴, 𝐶 (𝑆)
6. 𝑅⋈𝑆

Exercise 2 (2 points)
Consider University Database and give the table produced by the following two-line query:

𝑅←σ𝑏𝑢𝑖𝑙𝑑𝑖𝑛𝑔=𝑊𝑎𝑡𝑠𝑜𝑛(𝑑𝑒𝑝𝑎𝑟𝑡𝑚𝑒𝑛𝑡)

Π𝐼𝐷, 𝑛𝑎𝑚𝑒 (𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑜𝑟⋈𝑅)

Exercise 3 (2 points)
Consider University Database and write the following query in relational algebra: “List the IDs and names
of all instructors in the Physics department”.

Exercise 4 (2 points)
Let 𝑀 be a table with 𝑚 rows and 𝑁 be a table with 𝑛 rows. Let 𝑀⋈𝑁 be the natural join of these tables.
Answer the following two questions (1 point for each correct answer):
a. What is the minimum possible number of rows in 𝑀⋈𝑁?
b. What is the maximum possible number of rows in 𝑀⋈𝑁?

You might also like