100% found this document useful (1 vote)
967 views2 pages

1 Assignment-2

This document describes an exercise involving a database schema for products including PCs, laptops, and printers. It provides sample data and asks the student to write relational algebra queries to answer questions about the data. For question a) it asks for PC models with a speed of at least 3.00. For question f) it asks for hard disk sizes that occur in two or more PCs. For question h) it asks for manufacturers of at least two different computers with speeds of at least 2.80. The document then provides the correct relational algebra queries and results for each question, and common errors students make, particularly not understanding the difference between natural join and theta join.

Uploaded by

harsha sagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
967 views2 pages

1 Assignment-2

This document describes an exercise involving a database schema for products including PCs, laptops, and printers. It provides sample data and asks the student to write relational algebra queries to answer questions about the data. For question a) it asks for PC models with a speed of at least 3.00. For question f) it asks for hard disk sizes that occur in two or more PCs. For question h) it asks for manufacturers of at least two different computers with speeds of at least 2.80. The document then provides the correct relational algebra queries and results for each question, and common errors students make, particularly not understanding the difference between natural join and theta join.

Uploaded by

harsha sagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 2.4.

1:
This exercise builds upon the products schema of Exercise 2.3.2. Recall that the
database schema consists of four relations, whose schemas are:
Product(maker, model, type)
PC(model, speed, ram, hd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)
Some sample data for the relation Product is shown in Fig. 2.20. Sample data for
the other three relations is shown in Fig. 2.21. Manufacturers and model numbers have
been sanitized, but the data is typical of products on sale at the beginning of 2007.
Write expressions of relational algebra to answer the following queries. You may
use the linear notation of Section 2.4.13 if you wish. For the data of Figs, 2.20 and 2.21,
show the result of your query. However, your answer should work for arbitrary data,
not just the data of these figures.
a) What PC models have a speed of at least 3.00?
f) Find those hard-disk sizes that occur in two or more PCs.
h) Find those manufacturers of at least two different computers (PCs or laptops) with
speeds of at least 2.80.

Solutions:
a) The answer is:

(3.00 ())

Result:
1005
1006
1013
f) The answer is:
1 := 1 (PC)
2 := 2 (PC)
3 := 1 1.=2. 1.<>2. 2
R4 1. (3)

Result:
250
80
160
h) The answer is:
R1 := 2.8 (, () , ())
R2 := , (R1 Product)
R3 = 3(2,2) (R2)
R4 = R2 =2 <> 2 R3
Answer(maker) = (R4)

Result:
B
E

Errors from students:


The most significant problems encountered in f) and h) is that many students havent understood
the differences between NATURAL JOIN and THEAT JOIN. I can give an erroneous example about
f).

PC1 := , (PC)
PC2 := 2(,) (PC1)
Answer(hd) := (PC1 <> PC2)

The correct way should be:


Answer(hd) := . (PC1 <> .=. PC2)
OR
Answer(hd) := (<> (PC1 PC2))

Note:
Such error happens because many students believe THETA JOIN first do
NATURAL JOIN and then impose condition C. But actually, THETA JOIN
first do Cartesian Product and then impose condition C.

You might also like