





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






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:
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))}
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:
{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)}
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
Π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)}
12 g1 v 12 g2 v 12 g2 v 12 g3 v 41 g2 v 41 g3 v 41 g3 v 41 g4 v