Docsity

Midterm Exam Practice Problems - Database Design | COP 4710, Exams of Principles of Database Management

Partial preview of the text

Download Midterm Exam Practice Problems - Database Design | COP 4710 and more Exams Principles of Database Management in PDF only on Docsity!

EEL 4852 Database Systems

Fall 2008

Midterm Exam

Oct 9, 2008

Time: 75 minutes

Your Name: ___________________________

USF ID: __U_________________________

Problem I. (10pts)

True or false, mark your choice clearly. Ambiguous answers will get zero points.

1. SQL is an implementation of the domain relational calculus. T ( ) F ( X )

2. Relational algebra is a procedural language. T ( X ) F ( )

3. A foreign key must be a key in the referenced table. T ( X ) F ( )

4. A foreign key must be a key in the referencing table. T ( ) F ( X )

5. A DBMS is a software system that enables users to create and maintain a

database. T ( X ) F ( )

Problem II. (30pts, 5pts for each question)

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 ) The Catalog relation lists the prices charged for parts by Suppliers. The following foreign key constraints are specified: pid in Catalog referencing pid in Parts sid in Catalog referencing sid in Suppliers Write the following queries in relational algebra.

1. Find the names of all red parts.

!"#$%

  1. Find the names of parts that are red and supplied by a supplier located at “221 Parker Avenue”;

!"#$%

  1. Find the names of suppliers who supply every red part;

!"#$%,!"#,!"!

÷ !!"#"$!!"#(!)

!"#

  1. Find pairs of sids of such that the suppliers with the first sid charges more for some part than the supplier with the second sid does for the same part; ρ(R1, Catalog) ρ(R2, Catalog) πR1.sid,R2.sid (σR1.pid=R2.pid R1.sid !=R2.sid R1.cost>R2.cost (R1 × R2))
  2. For each part, print the pid and the average price (cost) all its suppliers charge;
  1. Find the names of suppliers who supply EVERY part; SELECT S.sname FROM Suppliers S WHERE NOT EXISTS (( SELECT P.pid FROM Parts P ) EXCEPT ( SELECT C.pid FROM Catalog C WHERE C.sid = S.sid ))

Problem IV. (30pts, 5pts each)

Consider the following two relations: Relation r Relation s B C D D E F a 5 b b 10 6 b 6 a c 25 3 c 25 b b 10 5 a 5 c show the results of the following relational algebraic expressions. Give ∅ as your answer if you think the operation(s) makes no sense. Show intermediate results for partial credits.

a. ! !!!!(!)

b. !⋈! (hint: natural join)

c. !⋈!.!!!.! !"# !.!!!.!!

d.! ∪!

e. !,!! − !,!(!)