Docsity

Assignment 2 for Database Management System | COP 5725, Assignments of Computer Science

Toggle sidebar
bg1
Database Management Systems (COP 5725)
(Fall 2008)
Instructor: Dr. Markus Schneider
TA:
Mingsong Chen
Wenjie Yuan
Homework 2
Name:
UFID:
Email Address:
Pledge (Must be signed according to UF Honor Code)
On my honor, I have neither given nor received unauthorized aid in doing this
assignment.
_______________________________________________Signature
For scoring use only:
Maximum Received
Exercise 1 15
Exercise 2 10
Exercise 3 20
Exercise 4 35
Exercise 5 20
Total 100
pf3
pf4
pf5

Partial preview of the text

Download Assignment 2 for Database Management System | COP 5725 and more Assignments Computer Science in PDF only on Docsity!

Database Management Systems (COP 5725)

(Fall 2008)

Instructor: Dr. Markus Schneider

TA:

Mingsong Chen Wenjie Yuan

Homework 2

Name: UFID: Email Address:

Pledge (Must be signed according to UF Honor Code)

On my honor, I have neither given nor received unauthorized aid in doing this assignment.

_______________________________________________Signature

For scoring use only:

Maximum Received

Exercise 1 15 Exercise 2 10

Exercise 3 20

Exercise 4 35

Exercise 5 20

Total 100

Exercise 1 (ER Model) [15 points]

Let E 1 , E 2 , and E 3 be entity sets, R 1 (E 1 , E 2 ), R 2 (E 2 , E 3 ), and R 3 (E 3 , E 1 ) be binary relationship sets, and R(E 1 , E 2 , E 3 ) be a ternary relationship set. The question is whether the three binary relationship sets R 1 , R 2 , and R 3 together do have the same expressiveness as the ternary relationship R. This is the case if each triple from R can be represented by three pairs of R 1 , R 2 , and R 3 , and vice versa.

  1. Do R 1 , R 2 , and R 3 on the one hand and R on the other hand have the same expressiveness, yes or no [ 3 points]?
  2. Give reasons for your answer in (i). If you answered yes, explain why both kinds of modeling have the same expressiveness. If you answered no, explain why both kinds of modeling have different expressiveness and which kind of modeling is less expressive than the other one [ 6 points].
  3. How many triples can we maximally represent in R? How many pairs of R 1 , R 2 , and R 3 can we combine [ 6 points]?

Exercise 3 (Relations) [20 points]

Let R and S be two given relations. R contains r tuples and S contains s tuples. Further, it is given that 0 < r < s. If we measure the size of a relation in terms of the number of tuples, then the sizes of R and S are r and s respectively. Give the minimum and maximum possible sizes for the resulting relation produced by each of the following relational algebra expressions. In each case, state the assumptions about the schemas R and S needed to make the expression meaningful. (a) R ∪ S (2 points) (b) R ∩ S (2 points) (c) R − S (3 points) (d) S − R (3 points) (e) R × S (2 points)

(f) σ a = 5 ( R )Assumption: R has an attribute named a. (4 points)

(g) π a ( R )Assumption: R has an attribute named a. (4 points)

Exercise 4 (Relational Algebra) [35 points]

Consider the following schema:

Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real)

(a) The key fields are underlined, and the domain of each field is listed after the field name. Therefore sid is the key for Suppliers, pid is the key for Parts, and sid and pid together form the key for Catalog. The Catalog relation lists the prices charged for parts by Suppliers. For each of the following relational algebra queries, say in English what they mean. If the meanings are the same, compare them and explain which one is better (10 points).

1. π sname ( σ color =' red ' ( parts )  σcos t = 100 ( Catalog )  Supplier )

2. π s name ( π sid ( σ color =' red ' ( parts )  σcos t = 100 ( Catalog ))  Supplier )

  1. '^ '^ cos^100 ' ' cos 100

color red t co

sname snam e lor green t

parts Catalog Supplier parts Catalog Supplier

= = = =

  1. '^ '^ cos^100 ' ' cos 100

sid col si

or red t d color green t

parts Catalog Supplier parts Catalog Supplier

= = = =

  1. ,^ '^ '^ cos^100 , ' ' cos 100

sid sname color red t color green

sname sid sna me t

parts Catalog Supplier parts Catalog Supplier

π σ σ σ σ

π π

= = = =

(b) Write the following queries in relational algebra (25 points)

  1. [2 points] Find the names of suppliers who supply some red part.
  2. [2 points] Find the sids of suppliers who supply some red or green part.
  3. [2 points] Find the sids of suppliers who supply some red part or are at 221 Packer Street.
  4. [2 points] Find the sids of suppliers who supply every part.
  5. [2 points] Find the sids of suppliers who supply every red part.
  6. [3 points] Find the sids of suppliers who supply every red or green part.
  7. [3 points] Find the sids of suppliers who supply every red part or supply every green part.
  8. [3 points] Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid.
  9. [3 points] Find the pids of parts supplied by at least two different suppliers.
  10. [3 points] Find the pids of the most expensive parts supplied by suppliers named Yosemite Sham.