Docsity

Test 1 Questions with Solution - Database Systems | CPSC 310, Exams of Deductive Database Systems

Toggle sidebar
bg1
Summer’2007 – CPSC310-300/CPSC603-300, Dr. Salih Yurtta¸s.
Test-1
I. (60 points.)
Relational Database Schema y-PC = (Product-schema,
PC-schema,
Laptop-schema,
Printer-schema)
is given with the following relation schemas:
Product-schema = (maker, model, type)
PC-schema = (model, speed, ram, hd, cd, price)
Laptop-schema = (model, speed, ram, hd, screen, price)
Printer-schema = (model, color, type, price)
Assume that the y-PC database is instantiated and you are asked
to write queries in different languages, such as: relational algebra(ra),
tuple relational calculus(trc), and domain relational calculus(drc) for
the following:
1. (30 points.) (ra,trc,drc)
Which manufacturers make laptops with a screen of 11 inches?
r1←σscreen=11(Laptop)
r2←Πmodel(r1)
r3←r21P roduct
r←Πmaker(r3)
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Test 1 Questions with Solution - Database Systems | CPSC 310 and more Exams Deductive Database Systems in PDF only on Docsity!

Summer’2007 – CPSC310-300/CPSC603-300, Dr. Salih Yurtta¸s. Test-

I. (60 points.) Relational Database Schema y-PC = (Product-schema, PC-schema, Laptop-schema, Printer-schema) is given with the following relation schemas:

Product-schema = (maker, model, type) PC-schema = (model, speed, ram, hd, cd, price) Laptop-schema = (model, speed, ram, hd, screen, price) Printer-schema = (model, color, type, price)

Assume that the y-PC database is instantiated and you are asked to write queries in different languages, such as: relational algebra(ra), tuple relational calculus(trc), and domain relational calculus(drc) for the following:

  1. (30 points.) (ra,trc,drc)

Which manufacturers make laptops with a screen of 11 inches?

r 1 ← σscreen=11(Laptop) r 2 ← Πmodel(r1) r 3 ← r 2 1 P roduct r ← Πmaker(r3)

{t | ∃u ∈ Laptop ∧∃v ∈ P roduct(t[maker] = v[maker] ∧u[model] = v[model] ∧u[screen] = 11)}

{< a >| ∃b, c(< a, b, c >∈ P roduct ∧ ∃b, d, e, f, g, h(< b, d, e, f, g, h >∈ Laptop ∧g = 11))}

  1. (10 points.) (ra)

Find the model number and price of all laptops made by manu- facturers C or E or K.

r 1 ← σmaker=′C′∨maker=′E′∨maker=′K′^ (P roduct) r 2 ← Πmodel(r1) r 3 ← r 2 1 Laptop r ← Πmodel,price(r3)

IV. (40 points.) The database schema consists of four relations, whose schemas are: Relational Database Schema PQRS = (P-schema, Q-schema, R-schema, S-schema) is given with the following relation schemas: P(A, B, C) Q(A, B, V, G) R(A, D, B, G, N) S(H, G) Consider the three tables p, q, and r, s are on schemas P, Q, and R, S respectively.

A B C 12 b1 c 12 bb c 41 bbb c 41 bbbb c Table 1: p

H G h1 g h2 g h3 g h4 g Table 2: s

Write down the tuple relational calculus and domain relational calculus queries with the result tables:

  1. (20 points.) (trc, drc) q 1 p 1 s

{t | ∃u ∈ q ∃v ∈ p ∃w ∈ s(t[A] = u[A] ∧t[B] = u[B] ∧t[V ] = u[V ] ∧t[G] = u[G] ∧t[C] = v[C] ∧t[H] = w[H] ∧u[A] = v[A] ∧u[B] = v[B] ∧v[G] = w[G])}

{< a, b, v, g, c, h > | (< a, b, v, g >∈ q ∧ < a, b, c >∈ p ∧ < h, g >∈ s)}

A B V G C H

12 b v1 g1 c1 h 12 b v2 g2 c1 h 12 bb v3 g2 c1 h 12 bb v1 g3 c1 h 41 bbb v4 g2 c1 h 41 bbb v5 g3 c1 h 41 bbbb v4 g3 c2 h 41 bbbb v6 g4 c2 h

  1. (10 points.) (trc, drc)

ΠA,G,V (q)

{t | ∃u ∈ q(t[A] = u[A] ∧ t[G] = u[G] ∧ t[V ] = u[V ])}

{< a, g, v > | ∃b(< a, b, v, g >∈ q)}

A G V

12 g1 v 12 g2 v 12 g2 v 12 g3 v 41 g2 v 41 g3 v 41 g3 v 41 g4 v