0% found this document useful (0 votes)
16 views4 pages

DBI202

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

*Bai 4 – chap2

A database schema consist of 4 relations:


 Product(maker, model, type)
 PC(model, speed, ram, hd, price)
 Laptop(model, speed, ram, hd, screen, price)
 Printer(model, color, type, price)

1,What types of product made by manufacturer A?

π type (maker=A (Product))


2,What PC models have a speed of at least 3.00?

πmodel (speed ≥ 3.00 (PC))


3,What types of product made by both manufacturers A and D?

πtype (maker=’A’ (Product))  πtype (maker=’D’ (Product))


4,What types of product made by manufacturer A but not by manufacturer D?

π type (maker=’A’ (Product)) − πtype (maker=’D’ (Product))


5,Which manufacturers make laptops with a hard disk of at least 100GB?

HD  πmodel, hd (hd ≥ 100 (laptop)

πmaker (product. model=HD. model (product × HD))

6,Find the model numbers and price of all products (of any type) made by
manufacturer B?

πmodel, price (maker=’B’ (Product)) ⋈ (πmodel, price (PC)  πmodel, price (laptop) 
πmodel, price (Printer))
7,Find the model number of all color laser printers?

πmodel (color=’true’ Ʌ type=’laser’ (Printer))


8,Find those manufacturers that sell Laptops, but not PC’s.

πmaker (type =’Laptop’ (Product))’− πmaker (type =’PC’ (Product))


9,Find those hard-disk sizes that occur in two or more PC’s.

R1  ρPC1(PC)

R2  ρPC2(PC)

R3  R1 ⋈ (PC1.hd = PC2.hd Ʌ PC1.model <> PC2.model) R2

R4  πhd (R3)
10,Find the manufacturers of the computer with the highest available speed.

A  πmaker, speed (Product. model= PC. model (Product × PC))  πmaker, speed (Product.
model= Laptop. model (Product × Laptop))

B  B(model2, speed2) (A)

C  πmodel, speed (A⋈ (speed<speed2) B)

πmaker((A-C) × Product)
11,Find those manufacturers of at least two different computers (PC or laptop)
with speeds of at least 2.80.

A  πmodel (speed ≥ 2.80(PC))  πmodel (speed ≥ 2.80(Laptop))


B  πmaker, model (A × Product)
C  C(maker2, model2) (B)

D  B⋈ (maker=maker2 ʌ model<>model2) C
πmaker (D)

*Bai 5- chap2
 Give a schema:
PC (Model, Speed, RAM, HDD, Price)
 Use Relational Algebra to express following constraints:

A PC with a processor speed less than 3.00 must not sell for more than
$800
speed<3.00 ʌ price ≤ 800(PC)

You might also like