You are on page 1of 9

Assignment 1 Product (maker, model, type) PC (model, speed, ram, hd, rd, price) Laptop (model, speed, ram,

hd, screen, price) Printer (model, color, type, price)

a. Find the model number, speed, and hard-disk size for all PCs whose price is under 1!"". #$%$C& model, speed, hd F'() PC *+$'$ price,1!""

b. -o the same as .a/, but rename the speed column megahertz and the hd column gigabytes. #$%$C& model, speed A# megahertz, hd A# gigab0tes F'() PC *+$'$ price,1!"" c. Find all the manufacturers of printers. #$%$C& -1#&12C& maker F'() Product *+$'$ t0pe34printer4 d. Find the model number, memor0 size, and screen size for laptops costing more than 5""". #$%$C& model, ram, screen F'() %aptop

*+$'$ price65"""

e. Find all the tuples in the printer relation for color printers. 'emember that color is a 7oolean-8alued attribute. #$%$C& 9 F'() Printer *+$'$ color3true

f. Find the model number, speed, and hard disk size for those PCs that ha8e either a 1!: or 1;: -<- and a price less than 1!"". =ou ma0 regard the rd attribute as ha8ing a string t0pe #$%$C& model, speed, hd F'() PC *+$'$ .rd %1>$ 41!:?4 (' rd %1>$ 41;:?4/ A2- price , 1!""@

Assignment !

Movie (title, year, length, inColor, studioName, producerC#) StarsIn (movieTitle, movieYear, starName) MovieStar(name, address, gender, birthdate) MovieExec(name, address, cert#, netWorth) Studio(name, address, presC#)

a. *ho were the male stars in &erms of $ndearmentA

#$%$C& star2ame F'() #tars1n, )o8ie#tar *+$'$ #tars1n.star2ame3)o8ie#tar.name A2- mo8ie&itle34&erms of $ndearment4 A2- gender34)4

b. *hich stars appeared in mo8ies produced b0 )B) in 1CCDA #$%$C& star2ame F'() #tars1n, )o8ie *+$'$ studio2ame 3 4)B)4 A2- 0ear 3 1CCD A2- #tars1n.mo8ie&itle3)o8ie.title

c. *hich mo8ies are longer than Bone with the *indA

#$%$C& m1.title F'() mo8ie m1, mo8ie m! *+$'$ m1.length6m!.length A2- m!.title3EBone with the *indE

d. *hich e:ecuti8es are worth more than )er8 BriffinA #$%$C& e1.name F'() )o8ie$:ec e1, )o8ie$:ec e! *+$'$ e!.name34)er8 Briffin4 A2- e1.net*orth 6 e!.net*orth

Assignment F

a. Bi8e the manufacturer and speed of laptops with a hard disk of at least thirt0 megab0tes.

#$%$C& maker, speed F'() Product 2A&G'A% H(12 %aptop *+$'$ hd63F"

b. Find those manufacturers who sell laptops, but not PCs. #$%$C& maker F'() Product *+$'$ t0pe34%aptop4 A2- maker 2(& 12 .#$%$C& maker from Product *+$'$ t0pe34PC4/

c. Find those pairs of PC models that ha8e both the same speed and 'A). #$%$C& p1.model, p!.model

F'() PC p1, PC p! *+$'$ p1.speed3p!.speed A2- p1.ram3p!.ram A2- p1.model6p!.model

Assignment 5 Gse subIueries for each Iuer0. a. Find the makers of PCs with a speed of at least 1!"". #$%$C& maker F'() product *+$'$ model 12 .#$%$C& model F'() PC *+$'$ speed631!""/ b. Find the printers with the highest price. Select model from Printer where price >= ALL (Select price from printer) c. Find the laptops whose speed is slower than that of an0 PC. Select model from Laptop where speed <= ALL (Select speed from P ) d. Find the maker of the color printer with the lowest price. Select distinct ma!er from Prod"ct# Printer $here color=tr"e and Printer.model=Prod"ct.model And price <= ALL (Select price from Printer where color=tr"e) e. Find the maker.s/ of the PC.s/ with the fastest processor among all those PCs that ha8e the smallest amount of 'A). Select distinct ma!er from Prod"ct# P $here Prod"ct.model=P .model And %am <= ALL (Select ram from P ) And Speed >= ALL (Select speed from P where ram=(Select min(ram) from P ))

Assignment D Classes (class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) a. Find the number of battleship classes. Select co"nt (class) from lasses where type=&bb& b. Find the a8erage number of guns of battleship classes #elect A<B.numBuns/ from Classes where t0pe34bb4 c. Find the a8erage number of guns of battleships

#elect A<B.numBuns/ from #hips, Classes where #hips. Class 3 Classes.class and t0pe34bb4 d. Find for each class the 0ear in which the first ship of that class was launched. Select min(la"nched) from Ships gro"p by class e. Find for each class the number of ships of that class sunk in battle. Select co"nt(ship) from '"tcomes# Ships $here '"tcomes.ship=Ships.name A() '"tcomes.res"lt = *s"n!* +ro"p by class

f.

&he weight in pounds of the shell fired from a na8al gun is appro:imatel0 one half the cube of the bore in inches. Find the a8erage weight of the shell for each countr0s ships. Select a,g(bore-bore-bore./) from lasses# Ships $here lasses.class=ships.class

+ro"p by co"ntry